I have been converting almost 100% of my c# queries to Lamda expressions… once I figured out the protocol, it made more sense to me… A sample of the type of query I find needing alot is below:
//to find if a part exists:
bool partExists = Db.Part.Any(x=>x.Company == CompanyID && x.PartNum == myPart);
//to retrieve just the part's description:
string partDesc = Db.Part.Where(x=>x.Company == CompanyID && x.PartNum == myPart).Select(x=>x.PartDescription).FirstOrDefault() ?? "Not Found";
//to retrieve multiple field values:
var PRecord = Db.Part.Where(x=>x.Company == CompanyID && x.PartNum == myPart).Select(x=> new {x.PartDescription,x.IUOM}).FirstOrDefault();
//remember... we need to check for PRecord is null before processing