I’m trying to find an example implementation of the Unit Of Work pattern in Simple.Data. Does anybody have one? I’m currently using non generic repositories and have been told that implementing UoW is something to do.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If what you want from the Unit of Work is a set of insert/update/delete operations covered by a transaction, then that is supported:
(Note: this code assumes you’re using the Ado adapter, and IDENTITY refers to SQL Server, but the code will work on any of the Ado providers and on any adapter which supports transactions.)
If you want to be able to create a batch of operations and run them all in one go, then that’s not directly supported at the moment, but I’m open to feature requests or patches.
If you’re after change tracking on objects, one thing that might help to know is that as of Simple.Data 0.9, SimpleRecord implements ICloneable, so you can take a copy of a record just after selecting it and use it for comparison when saving back. I’m going to push a release soon with support for an Update(current, original) method which will do optimistic-concurrency updates.