EntityFrameWork5.0 simple to use
Profile:
Use EntityFrameWork5.0 to execute stored procedures, SQL statements (DDL/DML), and a little bit about optimizing performance;
Body:
A stored procedure (select) that needs to present the data is included under MYEF.TT
The Model browser is as follows
1.EF How to call a stored procedure:
Note: The entity for the database table, expressed as a class object, can be manipulated directly under the EF container, such as db. UserAccount directly to UserAccount entity objects, stored procedures, views are the same, but also can be obtained through the EF context container;
2.EF Execute SQL statement:
Note: In two cases, a query SQL, a non-query SQL, is defined in the context container under the database object, where the Sqlquery<t> () method supports generics;
3.EF Performance Optimization
<1> delayed loading and caching mechanisms
It is generally tolist () to execute SQL, usually by where (), Count (), any (), and so on, to generate the SQL statement, run to the call to execute SQL (or Manual tolist ());
In addition, under the same context container, if the query data is repeated, there will be a caching mechanism to optimize, not send SQL to execute again, but from the cache directly reuse;
<2> do not track queries
When we query the data, the context container will identify the state of the data as unchanged for management, if the next and need to save changes to the data query to delete operations, you can use the non-tracking query, so that the context container no longer tracking query data to improve performance;
4. Programming for Stored procedures
end!
Use EntityFramework 5.0 for Stored procedures (& Execute SQL, performance optimization)