Count in lambda expression

lambda, linq

Solution

You can do it like this:

return repository.Count(x => x.Location == "SomeLocation");

Problem

I am trying to run a query where I get the name of locations and the number of items in that location. So if i have a program that contains 3 locations I want to know how many programs are in that location..I need to use this with a lambda expression or linq to entities. ``` return Repository.Find(x => x.Location.Name.Count())...clearly missing something here. ``` we'll just assume I have a Program entity with ProgramID, ProgramName, LocationName...need to know how many programs are in at a location

Original source