//queryAllCustomers is an IEnumerable<Customer>
var queryAllCustomers = from cust in customers
select cust;
Filtering
var queryLondonCustomers = from cust in customers
where cust.City == "London"
select cust;
Grouping
// custQuery is an IEnumerable<IGrouping<string, Customer>>
var custQuery =
from cust in customers
group cust by cust.City into custGroup
where custGroup.Count() > 2
orderby custGroup.Key
select custGroup;
Joining
var innerJoinQuery =
from cust in customers
join dist in distributors on cust.City equals dist.City
select new { CustomerName = cust.Name, DistributorName = dist.Name };
Select and contains
var Result = (from t in db.View_Initiative
where t.IsDeleted == 0
orderby t.InitiativesPkID descending
select new
{
INITIATIVETITLE = (t.InitiativeTitle),
Businessplan = (db.BusinessPlans.Where(x => x.BusinessPlanPkID == t.BusinessPlanID).FirstOrDefault().BusinessPlanName),
OsoName = (db.MstrOSoOfficesMarkets.Where(x => x.OSOOfficesMarketsPkID == t.RelatedOsoOrMarketID).FirstOrDefault().Name),
OsoNameID = t.RelatedOsoOrMarketID
}).ToList().Where(x => keyList.Contains(x.OsoNameID.ToString())).ToList();