/// <summary> /// Creates a new Idenity Scope. Close it with Dispose /// Must be created inside an TransactionScope /// it is strongy recommanded to create this class inside an using construct! /// </summary> /// <param name="rewriteDefaultValues">Should every DefaultValue still be set to a valid Id</param> public IdentityInsertScope(bool rewriteDefaultValues = false) { RewriteDefaultValues = rewriteDefaultValues; if (Current != null) throw new InvalidOperationException("Nested Identity Scopes are not supported"); if (Transaction.Current == null) throw new InvalidOperationException("Has to be executed inside a valid TransactionScope"); if (Current == null) Current = new IdentityInsertScope(rewriteDefaultValues, true); }
/// <summary> /// </summary> internal abstract void SetStore(IdentityInsertScope item);
internal override void SetStore(IdentityInsertScope item) { Current = (DbIdentityInsertScope)item; }
internal override void SetStore(IdentityInsertScope item) { Current.Value = (DbReposetoryIdentityInsertScope)item; }
public void Dispose() { OnOnIdentityInsertCompleted(); Current = null; }