Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework - One application/One user/One simple use case ... seem simple but is not
    text
    copied!<p>I have a simple time sheet application. It manages:</p> <ul> <li>Group of employees</li> <li>Employees</li> <li>A list of WorkEntry for each Employee</li> </ul> <p>The use case is the following:</p> <ol> <li>My user start the application and connect to a database.</li> <li>He looks at his WorkEntry for the day.</li> <li>He adds 2 new WorkEntries, but is <strong>NOT</strong> saving the data right now.</li> <li>He prints the WorkEntries, a dialog is showing him the progression of the operation which can take some time to complete.</li> </ol> <hr> <p>When I first started the application, I had a single ObjectContext created at the connection (in the UI thread) and disposed when the user closed the application. </p> <p>It was working quite well, but I faced a problem implementing the printing function because I was not able to use the ObjectContext in a background worker thread.</p> <p>Googling a little bit I found the concept of unit of work. </p> <ul> <li>Create the ObjectContext</li> <li>Do want you want to do</li> <li>Close it</li> </ul> <p>Also, my understanding is that entities are belonging to one ObjectContext. </p> <p>Let say ObjectContext#1 - Is used in the UI thread to retreive WorkEntries for the day - Contains the two new WorkEntries of the user. - Is not yet disposed because the user has not saved his changes</p> <p>Let say ObjectContext#2 - Is used in the background worker thread - Retreive WorkEntries for the day - Print the WorkEntries</p> <p>How can ObjectContext#2 be aware of the two new WorkEntries in ObjectContext#1?</p> <hr> <p><strong>EDIT</strong></p> <p>I know there is a flaw ... the user MUST save to get the two new entries in the printed report.</p> <p>But let say my application is presenting the data in a grid, like excel. The user will expect (<em>with good reasons</em>) the same behavior has excel. That is, in excel, I'm not forced to save to print my new rows ... I just want to print what I see on my sheet, no matter the persistence state of the data presented.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload