using System;
using System.Collections.Generic;
using System.Linq;
namespace LINQ2
{
class Program
{
static List<Customer> Customers = new List<Customer>();
static List<Notebook> Notebooks = new List<Notebook>();
static List<Order> Orders = new List<Order>();
static void Main(string[] args)
{
PopulateData();
}
private static void PopulateData()
{
int c = 30;
string[] firstNames = { "John", "Pluto", "Scooby-Doo", "Burek", "Szarik" };
string[] lastNames = { "Lipowski", "Bukowski", "Dębowski", "Sosnowski", "Świerkowski" };
string[] cities = { "Bestwina", "Kaniów", "Ligota", "Meszna", "Godziszka" };
string[] countries = { "PL", "SK", "CZ", "LT", "DE" };
Random R = new Random();
for (int i = 0; i < c; i++)
{
Customers.Add(new Customer()
{
CustomerId = i,
FirstName = firstNames[R.Next(5)],
LastName = lastNames[R.Next(5)],
Addr = new Address() { City = cities[R.Next(5)], Country = countries[R.Next(5)] }
});
}
string[] makers = { "HP", "IBM", "MSI", "Dell" };
string[] cpus = { "i3", "i5", "i7", "Xeon E5" };
for (int i = 0; i < c; i++)
{
Notebooks.Add(new Notebook()
{
ComputerId = i,
Make = makers[R.Next(4)],
Price = 1000 + 100 * i,
RAM = (int)Math.Pow(2, R.Next(6)),
CPU = cpus[R.Next(4)],
Drive = (int)Math.Pow(2, R.Next(6))
});
}
for (int i = 0; i < 2*c; i++)
{
Orders.Add(new Order()
{
OrderId = i,
Date = DateTime.Now.AddDays(-1000*R.NextDouble()),
CustomerId = R.Next(c),
ProductIdQt = new Dictionary<int, int>() { { R.Next(0, 10), R.Next(10) },
{ R.Next(10, 20), R.Next(10) }, { R.Next(20, 30), R.Next(10) } }
});
}
}
}
class Customer
{
public int CustomerId;
public string FirstName, LastName;
public Address Addr;
}
class Address
{
public string City, Country;
}
class Order
{
public DateTime Date;
public int OrderId, CustomerId;
public Dictionary<int, int> ProductIdQt;
}
class Notebook
{
public int ComputerId;
public string Make;
public double Price;
public int RAM, Drive;
public string CPU;
}
}
Mam program napisany w C# słabo ogarniam linq a potrzebuje zapytania mieć do tego programu. Napisz tu kilka zapytań LINQ, np. wypisz wszystkich użytkowników mieszkających w Polsce, którzy kupili łącznie co najmniej 3 notobooki oraz inne zapytania.