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
|
Hello.
I have 2 tables, they correspond to two objects in the LightSpeed model. (Registry and User) I write the code using (UOW)
{ IDbTransaction tran = UOW.BeginTransaction(); try{ var query = new Query(typeof(DAL.User)) { Identifier = reg.Id }; UOW.Remove(query); query = new Query(typeof(DAL.Registry)) { Identifier = reg.Id }; UOW.Remove(reg); UOW.SaveChanges(); }catch (Exception ee){ tran.Rollback(); } tran.Commit(); } first removes User and Registry
while getting SQL SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
BEGIN DELETE FROM Registry WHERE Registry.Id = 42; DELETE FROM users WHERE users.userID = 42 ROLLBACK ie SQL is in the reverse order to what was in the code.
|
|
|
This occurs because you have a typo in your code. Your second call to Remove is this: UOW.Remove(reg); which removes the reg entity using IUnitOfWork.Remove(Entity), not the updated query using IUnitOfWork.Remove(Query). And LightSpeed runs all Remove(Entity) calls before it runs any Remove(Query) calls. (It does this because Remove(Entity) calls have to be ordered by dependency, but Remove(Query) calls are opaque and have to be ordered by the user.) Change your second Remove to UOW.Remove(query) and you should see the SQL DELETE statements being emitted in the order you intended. |
|
|
O! I'm sorry, it's really very stupid mistake. |
|