LINQ Projections
You probably remember from Chapter 1 that in relational database theory a projection is a query that returns a subset of the fields in a row. LINQ supports projections, too. They’re returned as a new type, called an ANONYMOUS TYPE, that complies with the syntax for anonymous types in your language.
from s in context.Suppliers select new {s.FirstName, s.Surname}
From s in context.Suppliers Select New With {s.FirstName, s.Surname}
You can also assign a name to the anonymous type. In C# this requires a let
clause, but ...
Get Fluent Entity Framework now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.