Defines an Area that allows identity Inserts IDENTITY_INSERT on SQL
Inheritance: IDisposable
		/// <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);
		}
Example #2
0
 /// <summary>
 /// </summary>
 internal abstract void SetStore(IdentityInsertScope item);
Example #3
0
 internal override void SetStore(IdentityInsertScope item)
 {
     Current = (DbIdentityInsertScope)item;
 }
Example #4
0
 internal override void SetStore(IdentityInsertScope item)
 {
     Current.Value = (DbReposetoryIdentityInsertScope)item;
 }
		public void Dispose()
		{
			OnOnIdentityInsertCompleted();
			Current = null;
		}