简体   繁体   中英

Entity Framework 5 SqlQuery Slow Materializing

I am using EF 5, POCO objects, and SqlQuery. The materializing of objects is very slow about 20 seconds. If I run the SQL query using sql management studio the query runs in about 2 seconds. (example this.context.mytable.SqlQuery(query).AsNoTracking.ToList())

I was previously using this exact same SQL query with EF 4, Generated Entities and ExecuteStoreQuery. The materializing of objects was not as slow about 10 seconds.

Why the performance difference using POCO's? I have already tried using ExecuteStoreQuery from DbContext using the POCO's with the same slow (20 seconds) results.

Any Ideas?

In advance, thank you!

Update:

  1. entity classes:
    Two entity classes, one is a base class. Between the two there are about 27 columns/properties with most being on the base class.

  2. number of objects in selection result:
    About 75K.

  3. store query being executed:
    The query is a select (columns) from view where (1=1)

  4. API being used (DbContext or ObjectContext)
    In the EF 5/POCO scenario I am using DbContext.
    In the EF 4/Generated entities scenario I am using ObjectContext.

    **When using EF 5/DbContext I have also tried accessing the (lower level) ObjectContext and ExecuteStoreQuery method, that gave the same slow results as with DbContext SqlQuery.

错误的警报...最终导致poco的少量反射,从而在实现许多对象时降低了性能。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM