Desktop application using a database ... why is it so hard to meet client expectations?

I'm developing a desktop application in WPF, application that is manipulating a considerable amount of data stored in a database. The application presents that data using diagrams and grids.

I chose to access the data using Entity Framework (code first). It is easy to use and the lazy loading is something I was looking for. Searching the NET, I discovered that Entity Framework seems to be designed to be used in a "Unit Of Work" strategy.

Lets take 2 simple expectations from my client:

  1. I want to print my data and be informed of the print progress.
  2. I want to generate a PDF report and be informed of the generation progress.

The client is seeing grids so he is expecting something closed to Excel.

  1. Printing and report generation should take into account all modifications made to the data.
  2. The modifications are not valid until saved by the user.

For instance, open excel, modify a worksheet, print it and close the application discarding changes.

  1. All worksheet was printed, including not saved data
  2. If I reopen the file, the unsaved data is no more there.

Assuming that I open a DBContext in the UI thread to manipulate data and accumulate changes and that I want to do the export in another thread because it is time consuming (a new DBContext), my changes to the data are not taken into account, except if I save the data.

So, what should I do ...

  • Load the data from the database to XML files on disk and work on these files and put back the data on the database when saving?
  • Use a lot of imagination to put the DBContext in its own thread and make loading and lazy loading redirected to the DBContext thread?
  • Always save data in the DB, but when an "unsaved" flag or something like that?

Any suggestions are welcomed.

Answers


I would have the ViewModel expose an observable collection that gets loaded asynchrnosously so as to not block the UI thread. I would then expose a Command that provides the save functionality you are looking for. This way, you can access your modified objects (ObservableCollection) for printing and discard them if the user doesn't hit the Save Command.


Need Your Help

@autoreleasepool in loop or loop in @autoreleasepool?

iphone objective-c

It's a good practice to put lots of autoreleased object in an autoreleasepool at loop action. I found someone put the @autoreleasepool in loop but others put loop in @autoreleasepool.

slow extraction of json array elements in postgresql

postgresql

I have a json array and I want to expand each element to a new table. With the new json functions in postgresql 9.3, I expected this to be the best method: