Which LINQ to Entities query should you use?

You are developing an ASP.NET Web application. The application includes the following Entity Data
Mmodel (EDM)

You instantiate an ObjectContext for the EDM named context You need to find the total number of
addresses that are assosiated with customers that have a nonull mode. Which LINQ to Entities query
should you use?

You are developing an ASP.NET Web application. The application includes the following Entity Data
Mmodel (EDM)

You instantiate an ObjectContext for the EDM named context You need to find the total number of
addresses that are assosiated with customers that have a nonull mode. 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();



Leave a Reply 1

Your email address will not be published. Required fields are marked *