Wednesday, 15 September 2010

Questions about updates with Entity Framework -


I am still in the process of knowing all the ins and outs of the organization framework, and at present I find it useful To use ExecuteSqlCommand of the framework, on some big updates, as it is quite fast while processing too many updates (especially when I only need to update one field). My question is two times: First, is it a safe way to handle my updates? For my information, the standard way to update via EF will be like

  (user! = Null) {_Context.Entry (user) .CurrentValues.SetValues ​​(updatedUser); _Context.SaveChanges (); }  

or

  {_Context.Entry (Update User) .set = EntityState.Modified; _Context.SaveChanges (); }  

But both of these methods will be bugged down if the number of users is up to ~ 5000 to update, am I missing something, or am I accepting executivescale commodity ?

Secondly, if ExecuteSqlCommand is safe to rely on, then I can capture any such reference whose only purpose is to work it out, to make it every time I need it? My understanding is that in general, references should never be maintained because they slow down over time with usage, but I am wondering if this is right for such a limited use scenario. .

If my fundamental approach to using EF is in error, then I appreciate anyone paying attention to it. Thanks!

EF handles bulk operations at all, ExecuteSqlCommand as you mentioned) or third party Extensions are like.

If you are going to use the context for all, then calling ExecuteSqlCommand is better on demand and a normal SqlConnection and To renew SqlCommand , (although you will always use it every time you call, you will be using the back of the net, the connection to reuse the connection.)


No comments:

Post a Comment