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