Filtering
-----------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
var queryLondonCustomers = from cust in customers where cust.City == "London" select cust;
queryLondonCustomers.Where(p=>p.Cust_code>50)
Ordering
------------------------------------------------------------------------------------------
var queryLondonCustomers3 = from cust in customers where cust.City == "London" orderby cust.Name ascending select cust;
Grouping
-----------------------------------------------------------------------------------------
var queryCustomersByCity = from cust in customers group cust by cust.City; // customerGroup is an IGrouping<string, Customer> foreach (var customerGroup in queryCustomersByCity) { Console.WriteLine(customerGroup.Key); foreach (Customer customer in customerGroup) { Console.WriteLine(" {0}", customer.Name); } }
var custQuery = from cust in customers group cust by cust.City into custGroup where custGroup.Count() > 2 orderby custGroup.Key select custGroup;
Join
------------------------------------------------------------------------------------------
var innerJoinQuery = from cust in customers join dist in distributors on cust.City equals dist.City select new { CustomerName = cust.Name, DistributorName = dist.Name };
No comments:
Post a Comment