unit of work with different commit order

Posts   
 
    
imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 30-Aug-2010 18:20:14   

I am using unit of work where I want to do delete first before inserts. I am using following code but the delete is never get called although MyCollection.Count is greater than 0. Any idea what I may be doing wrong?


List<UnitOfWorkBlockType> CommitOrder = new List<UnitOfWorkBlockType>();
CommitOrder.Add(UnitOfWorkBlockType.Deletes);
CommitOrder.Add(UnitOfWorkBlockType.Inserts);
CommitOrder.Add(UnitOfWorkBlockType.Updates);

UnitOfWork uow = new UnitOfWork(CommitOrder);
....
MyObjectsDetailCollection MyCollection = new MyObjectsDetailCollection();
MyCollection.GetMulti(new PredicateExpression(MyObjectsDetailFields.Id == someId));
if (MyCollection.Count > 0)
    uow.AddDeleteMultiCall(MyCollection, new PredicateExpression(MyObjectsDetailFields. Id == someId));


for (int i = 0; i < SomeCounter; i++)
{
    MyObjectsDetailEntity MyEntity = new MyObjectsDetailEntity();
    MyEntity.IsNew = true;
    ......  
    ......  
    uow.AddForSave(MyEntity);
}
uow.Commit(new Transaction(System.Data.IsolationLevel.ReadUncommitted, "UOW"), true);


daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-Aug-2010 07:27:39   

It should work. Does the delete take place in a different order or it doesn't take place at all? What is your LLBLGen version and runtime library version? (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725)

David Elizondo | LLBLGen Support Team