c# - Error while querying Entity Framework, OutOfMemoryException or error when using context.AsNoTracking() -


i'm trying return application list application via json (using ajax). tried in 2 ways:

using select

var query = (from ad in db.addressnameplaces.asnotracking()                      ad.cepplace == zipcode.replace("-", string.empty)                      select ad ).tolist(); 

.where(expression) method:

var query = db.addressnameplaces.asnotracking().where(l => l.cepplace == zipcode.replace("-", string.empty)).tolist(); 

both of them works fine.

considerations: related tables in addressnameplace has on 770k records, , if use without .asnotracking() method, application returns json outofmemoryexception. entity framework instantiate lot of objects each record, , .asnotracking() method avoid it.

if use queries above, i'm getting following error: "when object returned notracking merge option, load can called when entitycollection or entityreference not contain objects."

so, what's wrong here?

i find solution case. before doing query, needed set false attribute "proxycreationenabled", code:

db.configuration.proxycreationenabled = false;         var query = db.addressnameplaces.asnotracking().where(l => l.cepplace == zipcode.replace("-", string.empty)).tolist(); 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -