Ashik_Manandhar wrote:
I'm working on a shopping cart wizard feature for my website. Right now, it's in Wizard format, so the user goes through a few pages putting in the data that is necessary. I want to use the UnitOfWork to get all this data, and then save it all together at the end of the Wizard. Only problem is, that I have a summary page as my last page, and I don't want to have the UnitOfWork save until the user submits through this last page. Is there a way for me to get the data out of the UnitOfWork to show up on the Summary page prior to saving that data?
Aye, it's a bit convoluted though as the UnitOfWork really wasn't designed for read access. The UnitOfWork was designed to accumulate instructions to be performed against the database, not as a penultimate validation container.
That being said, I use it this way,
but I have been considering creating a dedicated type for the purpose.
Anyway, you're looking for the GetEntityForInsert, GetCollectionForSave, GetFor methods of the class. They don't return entities or collections, but rather UnitOfWorkElement and UnitOfWorkCollectionElement types, which contain the entities and collections you're looking for. Unfortunately, you'll need to loop through the collections and test for types to find what you're looking for. I extended the UnitOfWork class to let me fetch entities or collections by type which works fairly well.
Jeff...