public static DbConnection GetStoreConnection(this EntityConnection entityConnection) { var storeConnectionProperty = entityConnection.GetType().GetProperty("StoreConnection", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); return((DbConnection)storeConnectionProperty.GetValue(entityConnection, null)); }
/// <summary>An EntityConnection extension method that gets the entity transaction.</summary> /// <param name="entityConnection">The entity connection to act on.</param> /// <returns>The entity transaction from the entity connection.</returns> internal static EntityTransaction GetEntityTransaction(this EntityConnection entityConnection) { var entityTransaction = entityConnection.GetType().GetField("_currentTransaction", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(entityConnection); return((EntityTransaction)entityTransaction); }