none
Getting current SqlCeTransaction from TransactionScope RRS feed

  • Question

  • How you retrieve a SqlCeTransaction object from a TranactionScope? Transaction.Current returns a Transaction object but this is not part of the same inheritence chain as SqlCeTransaction.

     Thanks.


    Monday, August 29, 2011 6:19 AM

Answers

  • Well I wasn't able to get the SqlCeTransaction from a TransactionScope but I am able to get a SqlCeTransaction this way:

    IObjectContextAdapter oca = MyDataContext as IObjectContextAdapter;
    EntityConnection ec = oca.ObjectContext.Connection as EntityConnection;
    ec.Open();
    SqlCeConnection connection = ec.StoreConnection as SqlCeConnection;
    SqlCeTransaction transaction = connection.BeginTransaction();
    

    I have to remember to Close the EntityConnection

     



    Monday, August 29, 2011 6:36 AM