This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have an adapter interface for using the UnitOfWork pattern with both LightSpeed and NHibernate on a couple different projects. One of the features is a disposable object similar to a TransactionScope, where if the scope is not completed before exiting the using block, any entity changes are discarded from the unit of work by clearing the entity cache. Creating the scope to begin with requires knowing that the UnitOfWork has no dirty entities in it. With NHibernate, I simply check IsDirty() on creation and Clear() if the changes are to be abandoned. I can't find equivalents of these in LightSpeed. Abandoning the unit of work and recreating would be an option, but I still need to be able to verify that doing so would not lose any pending changes that were made outside of the scope. Any suggestions?
|
|
|
We don't have a direct equivalent to Clear(). You can clear a unit of work by calling SaveChanges(true), but obviously that also commits any pending changes. For IsDirty(), you can easily create an extension method using the fact that IUnitOfWork is IEnumerable<Entity>: public static bool IsDirty(this IUnitOfWork unitOfWork) { |
|