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
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COI think there is a design flaw here; what if the worker adds two new WorkEntries and print out but does not save? IMHO, you should first force saving the data then enable printing.
      singulars
    2. COYou are right, there is a flaw ... but I don't want to force saving data to allow the user to print it, the user just want to print what he sees, no matter the persistance state. Let say I'm showing my data in a grid (like excel). Does excel force you to save before printing? Non, it just prints what you see on the screen.
      singulars
    3. COYes, but excel prints what it sees. If you have a shared excel spreadsheet and you are not connected to the network and hit print, then it just prints what it has in memory, not what might be out on the network. You can either print what is currently displayed to the user, what is only in the database, or both combined....however if you use the combined approach, then you must create a hybrid of getting the current database state, making sure it is synced (what if the user was doing a conflicting update), and then add on the in-memory items....personally, I would say just go with the in-memory
      singulars
 

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