4
votes

Are there any examples/tutorials/information on more advanced line of business applications? There is a great deal of information on understanding PRISM, MEF, MVVM, Entity Framework, generic repositories, mechanics behind prism and other MVVM frameworks such as regions, navigation etc.

I know how to connect to a database and switch views and create a basic application.

so at this point I have a DataGrid with a list of my database objects in it. Lets say at this point I even have templates and it all looks good to view.

How do you implement the last part of this to perform CRUD operations. Is it better to edit directly in the DataGrid and have update/add/remove buttons? Should it update on row change? What if I want a custom modal view to show to edit/add data? What is the best practice for the actual manipulation of data?

Are there any examples of a PRISM/MVVM/Entity Framework application that you can run and actually view/edit/delete records in a database?

All the examples I have found do not elaborate on how/why you should implement the final data implementation.

Quote from another answer in a similar question:

Samples included with PRISM cover all you need. Also, PRISM is about UI composition, data access is out of scope.

My question is about how to get data access working with PRISM, modal view, edit directly in grid etc.

The samples do not cover all I need, if one sample had a window that listed data in a database and provided CRUD functions then this would be true. Is there any samples that show how all of this works together?

1
waf.codeplex.com/documentation?referringTitle=Home is the closest thing I could find to what I am looking for. Is there anything else like this but PRISM oriented or any blog posts/ tutorials on which method of adding/updating records is best or which would be better depending on use case? - Darren
You usually will not find advanced applications as tutorials. Advanced applications are normally proprietary and the source code will not be released as it his a dollar value behind it. Your best bet would be to find an open source project that utilizes this - but your chances are slim. - tsells
Not looking for anything advanced. Just a single simple database table on SQL server. Show the data and allow add/edit functions for the data. There are 3 ways that I am thinking of right now, edit directly in the DataGrid, Master-Detail View, or a popup edit view. I have just searched "master details gridview prism" and this looks to be getting me somewhere now. - Darren
The biggest question for me is which one of those three ways would be best? Is there any best practice / preference? If I want to edit multiple tables with different data I am going to need multiple view/viewmodels to handle generating the table with the correct data templates. I am thinking if I use popups to edit I can create a single view/view model and extend it so when it is instantiated it will use the correct data templates and edit popup depending on the table/data type it is bound to. Does that sound right? These are the types of questions I am running into. - Darren

1 Answers

0
votes

Having done something similar in the past, I would create a data service whose only job is to facilitate data requests to/from the database and the user.

The data service is the only piece that actually knows how to talk to the db and those details should be obfuscated from the consumers (your viewmodels, etc.).

Once the data service is created, the service would hold onto the editable collection of tuples, handle modifications to any and all of them, and expose them directly for binding to the View, ideally through the ICollectionView interface.

Then, it's just a matter of injecting that service into your vm's (ideally through an interface to keep things unit testable).

I know these concepts are all high-level, but that's kind of all I can give you at this point. This is a project I wrote a while back to showcase MVVM and it has this idea in place, although the data store is not a database (but that isn't limited by the concept of a data service). Feel free to dig around in the source code of the project and hopefully you'll find something useful there.