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 use the SaveChanges() method of the unitOfWork object to commit the data to the database. How can I validate the data before calling save changes? I'm using VistaDB as database and I noticed that if the data is somehow invalid, I can an exception and then if I try to save the changes again I get a "Nested transaction not supported exception". How can I fix this problem, maybe cancelling the previous transaction so that I'm not stuck? Thanks. |
|
|
Call the Validate method or IsValid property, then consult the Errors property. You can do this for all entities in the unit of work by using the fact that the unit of work is IEnumerable<Entity> e.g. Dictionary<Entity, ValidationErrorCollection> entitiesWithErrors = (not tested) |
|
|
What should I do if I get unexpected errors? Can I cancel the entities with errors? One more thing: I saw that vistadb allows you to create just one transaction. If I try to commit the data and there's an error a transaction is started. How can I rollback it? I saw the code http://www.vistadb.net/onlinehelp/_2ch00k4s2.htm but how can I do it inside Lightspeed? Andrea |
|
|
[quote user="nagar"]What should I do if I get unexpected errors?[/quote] This is an application decision. You might remove them from the save, require the user to fix them... this is a business decision, we can't make it for you. If you want to exclude an entity from being saved, you can detach it from the UOW using UnitOfWork.Detach. You can't directly control LightSpeed's internal transactions. But you can start a transaction or TransactionScope yourself, in which case LightSpeed will use that instead of starting a transaction of its own. |
|