Microsoft
70-516 · Question #165
You are developing a new feature in the application to display a list of all bundled products. You need to write a LINQ query that will return a list of all bundled products. Which query expression…
The correct answer is D. context.Parts.OfType<Product>(). OfType() Filters the elements of an IEnumerable based on a specified type. Enumerable.OfType<TResult> Method
Querying Data
Question
You are developing a new feature in the application to display a list of all bundled products. You need to write a LINQ query that will return a list of all bundled products. Which query expression should you use?
Options
- Acontext.Parts.Cast<Product>()
- Bcontext.Parts.OfType<Product>()
- Ccontext.Parts.Cast<Product>()
- Dcontext.Parts.OfType<Product>()
How the community answered
(29 responses)- A7% (2)
- B3% (1)
- C10% (3)
- D79% (23)
Explanation
OfType() Filters the elements of an IEnumerable based on a specified type. Enumerable.OfType<TResult> Method
Topics
#LINQ to Entities#OfType#type filtering#inheritance
Community Discussion
No community discussion yet for this question.