/// <summary>An EntityConnection extension method that gets the store transaction.</summary> /// <param name="entityConnection">The entity connection to act on.</param> /// <returns>The store transaction from the entity connection.</returns> internal static DbTransaction GetStoreTransaction(this EntityConnection entityConnection) { var entityTransaction = entityConnection.GetEntityTransaction(); if (entityTransaction == null) { return(null); } var storeTransactionProperty = entityTransaction.GetType().GetProperty("StoreTransaction", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); return((DbTransaction)storeTransactionProperty.GetValue(entityTransaction, null)); }
/// <summary>An EntityConnection extension method that gets database transaction.</summary> /// <param name="entityConnection">The @this to act on.</param> /// <returns>The database transaction.</returns> public static DbTransaction GetDbTransaction(this EntityConnection entityConnection) { object entityTransaction = entityConnection.GetEntityTransaction(); if (entityTransaction == null) { return(null); } var transaction = entityTransaction.GetType().GetField("_storeTransaction", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(entityTransaction); return((DbTransaction)transaction); }