linq to entities query with projections in c#

A projection is the selection of required columns from a table or from set of tables which are joined together. Projections are used when we need to return objects with only some selective properties and also when we do not want these results to be updated and modified.

The below query demonstrates how to write LINQ to Entities query with projections in C#.
using (var context = new SalesOrderManagementEntities())
	var Customers = from c in context.Customer
					where c.Name == "VAM"
					select new { c.Name, c.CustomerId };
	foreach (var Customer in Customers)
The below LINQ to Entities query with projections in
Dim Customers = From c In context.Customer
				Where c.Name == "VAM"
				Select New With { c.Name, c.CustomerId }

Using Visual Studio 2008, we can implement LINQ projections very easily. Note that the LINQ to Entities projection returns an anonymous type. Anonymous types are used to create on-the-fly types which were not declared any where in the application.