How to know if UnitOfWork2.Commit was a success?

Posts   
 
    
Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 13-May-2007 22:06:39   

I am just curious how do know if a unit of work's commit operation has completed successfully.

For example, assuming I have a client table, I could write the following delete statemet: "Delete From Client Where ClientId = 1234". If I ran this in enterprise manager, it might or might not delete records. In any case, the SQL is valid and does execute.

I have a similar concept written in C# and I am trying to determine if the actual entities were deleted at runtime. Should I try and refetch the entities being deleted directly?

Or, better yet, what happens when you call UOW2.AddDeleteEntitiesDirectlyCall and there is no data to be deleted?

Here is my sample code:


internal override bool Delete(object UserId)
{
    bool result = false;

    if (UserId == null)
        throw new ApplicationException(Properties.EvClientMembershipProvider.Msg_UserIdRequired);

    Guid lUserId = (Guid)UserId;
    using (DataAccessAdapterBase adapter = AdapterFactory.CreateAdapter())
    {
        UnitOfWork2 uow = new UnitOfWork2();

        RelationPredicateBucket bucket = new RelationPredicateBucket(ClientUserFields.UserId == lUserId);

        uow.AddDeleteEntitiesDirectlyCall("ClientUserEntity", bucket);

        bucket = new RelationPredicateBucket(ClientContactFields.UserId == lUserId);
        uow.AddDeleteEntitiesDirectlyCall("ClientContact", bucket);

        uow.Commit(adapter, true);
        result = true;
    }

    return result;
}

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 14-May-2007 08:49:13