.net - Entity framework and deataching objects -


When creating a web application that uses the entity framework in the Access Layer, to separate objects from object references It is advisable to allow the object to collect garbage.

But since the web application has all the requests -> feedback applications, after the response is sent to the customer, the object context itself can not be captured by any live object. Rbhit is not, and therefore the object context and should be available for the attached object garbage collection, since there is no object survive any reference to them.

Do not I want to forget anything in this scenario or do not want to separate things?

I suspect that the guidelines you saw were about non-tracking queries Talking

There are certain performance advantages for reading deeper websites of no-tracking queries.

Objects never are not attached and tracked by identity, so you do not need to separate them, which avoids the cost of determining identity during materialism.

The tracking query looks like this:

  var source = ctx.Staff; Source.MergeOption == MergeOption.No Trekking; Var staff = (from source to s in s where select s.ID == 12). first ();  

There is no other advantage of tracking questions on manually-detached entities: manually disconnecting the unit from the rest of the unit, where there is no tracking query Are all different.

But there are some downsides to use non-tracking queries: You can sometimes end in such situations, where you read duplicate results because you closed Has given the resolution resolution.

So, unless you are really sure that your query is only going to copy the copy of each unit, you should be careful, or you may end up with a UI bug.

Alex

PS: This can be helpful for you.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -