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 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.
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) { Console.WriteLine(String.Format("{0}", Customer.CustomerId)); } Console.WriteLine(); }The below LINQ to Entities query with projections in Vb.net.
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.
Entity Framework Articles
- entity framework entity data model
- entity framework orm object relational mapper
- querying entity data model using objectcontext
- using ado net entity data model in windows applications.html
- create entity data model using ado.net entity framework designer in visual studio
- create-sales-order-management-data-model-using-edmgen-tool.html
- display data in a gridview using ado.net entity data source control
- ways of querying entity data model
- query entity data model using linq to entities
- query entity data model with object services and entity sql
- query entity data model using linq methods
- parameterized objectquery against a entity data model
- query entity data model entity client
- entity framework - save changes to entities
- entity framework - insert new objects
- add an entity to associated entities
- deleting entities using deleteobject() method of objectcontext
- entity framework load method
- eager loading using include method in entity framework
- entity framework - retrieving a single entity
Most Viewed
Azure Q & A
Azure Platform
Grid-View
GridView CommandField example
Details-View
GridView and DetailsView Master/Detail page using SqlDataSource control
POCO
POCO overview and advantages - POCO class, Entity Framework in Enterprise Applications
Entity Framework
Query entity data model using linq to entities
Array List
Difference between arraylist and list collection
Web Services
How to create a Web service using Visual Studio.net
Form-View
FormView DataBound Event
Object Oriented Programming
Calling base class constructor in C#
Linq
Convert a sequence to a generic list using ToList()method
Project Ideas
Project ideas for students
AccountingSoftware
Accounting Software
MVC
Creating an ASP.Net MVC 3 application
.Net
Using assemblies in .net applications
ASP .Net
How to implement form validation using ASP.Net 2.0 Validation Controls
VB .Net
Constructors in Visual Basic.Net