Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Linq3()
- {
- List<Product> products = GetProductList();
- var expensiveInStockProducts =
- from prod in products
- where prod.UnitsInStock != 0 && prod.UnitPrice > 3
- select prod;
- Console.WriteLine("In-stock products that cost more than 3.00:");
- foreach (var product in expensiveInStockProducts)
- {
- Console.WriteLine("{0} is in stock and costs more than 3.00.", product.ProductName);
- }
- }
- public void Linq4()
- {
- List<Customer> customers = GetCustomerList();
- var waCustomers =
- from customer in customers
- where customer.Region == "WA"
- select customer;
- Console.WriteLine("Customers from Washington and their orders:");
- foreach (var customer in waCustomers)
- {
- Console.WriteLine("Customer {0}: {1}", customer.CustomerID, customer.CompanyName);
- foreach (var order in customer.Orders)
- {
- Console.WriteLine(" Order {0}: {1}", order.OrderID, order.OrderDate);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment