Lambda expression Where is the navigation property

Good day,

I have three objects (which relate to this question)

Company (ID, etc.) CompanyAddress (AddressID, CompanyID, Rank) AddressDetails (AddressID, Street, City, State, Zip)

Cause The rank and company ID are not specified in AddressDetails, because these addresses are shared by contacts through the ContactAddress object.

In any case, I need to create an IQueryable with an IQueryable in mind, which checks if the string is contained in the City (and ultimately or in state). I would like to use Lambda expressions rather than syntax from c in companies... I tried

query = query.Select(c => c.Addresses.Where(a => a.AddressDetails.City.Contains(City)).Select(ca => ca.Company));

In this example, c.Addresses is the navigation property for CompanyAddress.

Thanks for any help

Floor

+3
1

, :

query = query.Where(c => c.Addresses.Any(a => a.AddressDetails.City.Contains(City)));

, IQueryable<Company>.

+4

Source: https://habr.com/ru/post/1726189/


All Articles