Any Pattern/Framework for CRUDing Business Objects?
In the past years I have been working on different projects that required creating business objects, filling them with data from DB and presenting them on the UI, manipulating them and saving them back into database.
There is a number of things that need everytime to be considered and created from scratch, that is a base class for business objects to implement IsDirty etc to to realize which objects have been changed in order to save them.
Another challenge is if the user applies several changes to several rows and wants to save them all at once. Sometimes t开发者_C百科here is a deletion of a row involved that itself is a hierarchy of a different record, hence there is a need for cascading, and if its deleted in the wrong order, if you crash the application with a key-not-found.
Also important what happens if a record is being edited by two different users, how to implement the right approach to time stamp them etc
These and many other concerns are happning over and over again and i wonder if there is a framework for this to give a guideline what needs to be done properly to eliminate bad surprises and need for late refactoring. Since there is always something you may forget in your design.
I am targeting .NET 3.5 and .NET 4.0. An only .NET 4.0 solution would also be interesting to know about.
Highly appreciated,
Entity Framework could be useful to you. It can automatically generate the Business Objects from the database and you can customize it as well. Change tracking can be implemented too.
It is fairly accommodating to late re-factoring. If you accept the default mapping that is generated by Visual studio, then re factoring is no work at all. We did some manual tweaking to the XML file and that caused some issues while updating the model from the database next time. But it is still quite manageable.
精彩评论