OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
ADO.NET Entity Framework 4: New and Notable Features | Articles | Recent Articles | News Article | Interesting Articles | Technology Articles | Articles On Education | Articles On Corporate | Company Articles | College Articles | Articles on Recession
Home » Articles » ADO.NET Entity Framework 4: New and Notable Features
ADO.NET Entity Framework 4: New and Notable Features
Article Posted On Date : Wednesday, March 21, 2012
ADO.NET Entity Framework 4: New and Notable Features
Advertisements
The ADO.NET Entity Framework is an extended object relational mapping (ORM) tool from Microsoft that has become increasingly popular over the past few years and is widely used these days. Microsoft designed the ADO.NET Entity Framework to objectify an application's data and simplify the development of data-aware applications. In the first article in this series on the ADO.NET Entity Framework, I discussed the basics and how to program against the Entity Data Model. This concluding article, I will discuss the new features in Entity Framework 4. Entity Framework 4.0 Prerequisites To work with Entity Framework and the code examples illustrated in this article, you should have the following installed in your system: Visual Studio 2008 with SP1 Entity Framework Version 4 Alternatively, you can simply have Visual Studio 2010 installed -- it comes with Entity Framework 4 by default. Code First Development with Entity Framework 4 Entity Framework 4 supports "code first development," enabling you to use the Entity Framework designer tool to design your object model and then use it to drive your relational or logical model. Programming the Entity Data Model You have a few choices for writing queries and executing them against the Entity Data Model, namely Object Services, Entity Client and LINQ. While Entity Client is the data provider to connect to the Entity Data Model and perform CRUD operations, Entity SQL is a data store-independent derivative of T-SQL. The following code snippet shows how you can use Object Services to query your data: using (NorthwindEntities dataContext = new NorthwindEntities()) { ObjectQuery<Products> products = dataContext.CreateQuery<Products>( "SELECT VALUE p FROM Products AS p"); foreach (Products p in products) { Console.WriteLine(p.ProductName); } } The same query can be re-written using LINQ as shown in the code snippet below: using (NorthwindEntities dataContext = new NorthwindEntities()) { var result = from p in dataContext.Products select p; foreach (Products product in result) { Console.WriteLine(product.ProductName); } } The Entity Client supports only Entity SQL as the query language. This is in contrast to Object Services, which allows you to use even LINQ to write your queries and execute them against the Entity Data Model. The following code snippet illustrates how you can use Entity Client: using (EntityConnection conn = new EntityConnection("name=TestEntities")) { conn.Open(); EntityCommand cmd = conn.CreateCommand(); cmd.CommandText = @" SELECT VALUE e FROM TestEntities.Managers AS e"; using (DbDataReader reader = cmd.ExecuteReader( CommandBehavior.SequentialAccess)) { while (reader.Read()) { Console.WriteLine( "Manager Name: {0}", reader["ManagerName"].ToString()); } } }
Amazon.in Widgets