Guest User

Untitled

a guest
May 5th, 2015
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. public void Linq3()
  2. {
  3.     List<Product> products = GetProductList();
  4.  
  5.     var expensiveInStockProducts =
  6.         from prod in products
  7.         where prod.UnitsInStock != 0 && prod.UnitPrice > 3
  8.         select prod;
  9.  
  10.     Console.WriteLine("In-stock products that cost more than 3.00:");
  11.     foreach (var product in expensiveInStockProducts)
  12.     {
  13.         Console.WriteLine("{0} is in stock and costs more than 3.00.", product.ProductName);
  14.     }
  15. }
  16.  
  17. public void Linq4()
  18. {
  19.     List<Customer> customers = GetCustomerList();
  20.  
  21.     var waCustomers =
  22.         from customer in customers
  23.         where customer.Region == "WA"
  24.         select customer;
  25.  
  26.     Console.WriteLine("Customers from Washington and their orders:");
  27.     foreach (var customer in waCustomers)
  28.     {
  29.         Console.WriteLine("Customer {0}: {1}", customer.CustomerID, customer.CompanyName);
  30.         foreach (var order in customer.Orders)
  31.         {
  32.             Console.WriteLine("  Order {0}: {1}", order.OrderID, order.OrderDate);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment