You are developing an ASP.NET web application. The application includes the following Entity Data
Model (EDM):
You instantiate an ObjectContext for the EDM named context. You need to find the total number of
addresses that are associated with customers that have a non-null middle name. Which LINQ to
Entities query should you use?
A.
var query = context.Customers
.Where(c => c.MiddleName != null)
.Select(c => c.CustomerAddresses.Count();
B.
var query = context.Customers
.Where(c => c.MiddleName != null)
.SelectMany(c => c.CustomerAddresses.Count();
C.
var query = context.Addresses
.SelectMany(a => a.CustomerAddresses.OfType<Customer>()
.Where(c => c.MiddleName != null)).Count();
D.
var query = context.Addresses
.GroupBy(a => a.CustomerAddresses
.Where(ca => ca.Customer.MiddleName != null)).Count();