Sunday 15 August 2010

entity framework - EF database concurrency -


I have two apps: one app is asp.net and another window is running in a window service.

The Windows service running in the background is doing some tasks (reading and updating) on ​​the database, while the user can perform other operations on the database via the asp.net app. So I'm worried about it, for example, in the windows I make some records that satisfy a condition and then I iterate over them, like something:

  IQueryable & Lt; EntityA & gt; Collection = Reference.Entiss.way (& lt; condition & gt;) Agram (existence unit in the collection) {// some stuff}   

Therefore, if the user modifies that record Which loop is used later, the value for that record is taken in the EF account? When originally done:

  context.EntitiesA.where ()   

or modified by the new user and located in the database ?

As far as I know, during the repetition, EF is taken on demand for every record, I mean, one by one, so when the next record for next recurrence is read This record is linked to:

  context.EntitiesA.where (& lt; condition & gt;)   

or located in database (user Has been modified now)?

Thank you!

There are some procedures that will come in the form of drama, how it will work in EF.

  1. Query is done only on calculation (this is sometimes referred to as query magnification) At this point the entire query will be done
  2. Your system is listed above Example:

    So what does this mean in your case:

      // There is nothing here. You are only describing that later / Execute one here to execute / query. .OARRA or similarly, to prevent people from adding to SQL / // as a result of this use. ANNIMERABLE IQueryable & lt; EntityA & gt; Collection = context.EntitiesA.where (& lt; condition & gt;); // When this first hit this foreach one // SELECT {Cols} FROM [YourTable] where [your condition] will be foreach (EntityA unit in the archive) {// data will start foreach from time to time (eg if you have database If you have updated during counting, you will have old data) // Do some things}    

No comments:

Post a Comment