Objective
The Entity Framework is the full name of the ADO framework, which is the ADO-based ORM (object/relational Mapping) architecture developed by Microsoft.
Key features of the Entity framework:
1. Support multiple databases (Microsoft SQL Server, Oracle, and DB2);
2. Strong mapping engine, can support the stored procedure well;
3. Provide Visual Studio integration tools for visual operation;
4. Can be well integrated with ASP. NET, WPF, WCF, WCF Data services.
Thinking? With EF We don't have to write our own SQL statements, what does EF really do, let's explore?
We know that the edmx file is the metadata of EF, so we open the edmx file in XML to see the data as shown below:
The SSDL in the figure represents the configuration node of the database, the CSDL entity configuration node, the C-s entity and the database relational mappings.
We found that the GroupInfo node XML data in the SSDL configuration node conforms to the data in our data. Such as
SSDL represents the GroupInfo in the configuration node of the database
GroupInfo in the CSDL entity configuration node
C-s GroupInfo in relational mappings for entities and databases
Knowing this, let's see how EF actually generates SQL
Private void button1_click (object sender, EventArgs e) { //1.0 Instantiate the EF Context container class object new phonebookentities (); // 2.0 querying id<209 all data in Gropuinfo 209). ToList (). ForEach (c = Console.WriteLine (c.groupname)); }
From the code and analysis diagram we can see:
1.EF tightly is a layer of packaging, and ultimately to the bottom of the call ADO
2.EF is only responsible for generating SQL statements, sent to ado.net,ado.net responsible for reading data from the DB, and ultimately returning to our EF
Description of the structure of the EDMX Metadata Acquisition DB table in 3.EF
4. The query SQL statement we want to generate select Groupid,groupname,grouptype from GroupInfo these can be obtained from the metadata where the conditions can be determined by our C + = C.groupid < 209 Offers
The mystery of EF is uncovered by US ~ ~ ~
If you feel good after reading this article, please click " attention " in the upper left corner to support the blogger, thank you!
If you feel good reading this article, please click on the bottom right corner of the
"recommended"
Feng Ling Yi
QQ: 616931
Source:Http://www.cnblogs.com/fenglingyi
statement: The copyright of this article is owned by the author and the blog park, without the author's consent must retain the statement, and in the article page obvious location to the original link, otherwise reserve the right to pursue legal responsibility
Original Entity Framework Query principle