Linq to Entities: complex query getting “average” restaurant rating?

It should end up looking something like this: var avgForMatches = (from r in context. Restaurants where r.Cuisines. Any(c => c.

CuisineName == cuisineName) where r.Prices. Any(p => p. PriceCode == priceCode) //... same pattern for other searches.

Select r. RatingCode) .Average().

Wow .... that is so simple. One more question, 'context' ... is that a reserved word or does that refer to my entities model? – Susan Jul 14 at 19:15 Yes, it is simple.Be warned: LINQ can get really addictive.

;-) context is just the variable that refers to your entity model instance. I usually wrap EF query code in something like using (var context = new MyEntityContext()) {...}.(Actually, I usually use an injected factory, rather than creating it myself, but you get the general idea.) – StriplingWarrior Jul 14 at 19:46.

Read about aggregate methods (including average) within the 101 linq samples - msdn.microsoft.com/en-us/vcsharp/aa336747.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions