private void SavePartialChangeGroup() { if (null != m_runTimeChangeGroup) { return; } SqlChangeGroupManager manager = this.Manager as SqlChangeGroupManager; Debug.Assert(null != manager, "Manager is not a SqlChangeGroupManager for SqlChangeGroup"); using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { try { context.Attach(manager.RunTimeMigrationSource); context.Attach(manager.RuntimeSessionRun); // save group attributes m_runTimeChangeGroup = RTChangeGroup.CreateRTChangeGroup(-1, ExecutionOrder, SessionId, SourceId, (int)ChangeStatus.ChangeCreationInProgress, false); m_runTimeChangeGroup.Owner = Owner; m_runTimeChangeGroup.Comment = Comment; // Store the ChangeTimeUtc value in the RevsionTime column unless the ChangeTimeUtc is not set (MinValue) // If it's not set, store DateTime.MaxValue to indicate that because DateTime.MinValue is outside the range allowed by SQL m_runTimeChangeGroup.RevisionTime = ChangeTimeUtc.Equals(DateTime.MinValue) ? DateTime.MaxValue : ChangeTimeUtc; m_runTimeChangeGroup.StartTime = DateTime.UtcNow; m_runTimeChangeGroup.Name = Name; m_runTimeChangeGroup.ReflectedChangeGroupId = ReflectedChangeGroupId; m_runTimeChangeGroup.UsePagedActions = m_usePagedActions; m_runTimeChangeGroup.IsForcedSync = IsForcedSync; // establish SessionRun association m_runTimeChangeGroup.SessionRun = manager.RuntimeSessionRun; // estabilish MigrationSource association m_runTimeChangeGroup.SourceSideMigrationSource = manager.RunTimeMigrationSource; // save the group context.AddToRTChangeGroupSet(m_runTimeChangeGroup); context.TrySaveChanges(); // record internal Id this.ChangeGroupId = m_runTimeChangeGroup.Id; } finally { context.Detach(m_runTimeChangeGroup); context.Detach(manager.RunTimeMigrationSource); context.Detach(manager.RuntimeSessionRun); } } }
private void SavePartialChangeGroup() { if (null != m_runTimeChangeGroup) { return; } SqlChangeGroupManager manager = this.Manager as SqlChangeGroupManager; Debug.Assert(null != manager, "Manager is not a SqlChangeGroupManager for SqlChangeGroup"); using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { try { context.Attach(manager.RunTimeMigrationSource); context.Attach(manager.RuntimeSessionRun); // save group attributes m_runTimeChangeGroup = RTChangeGroup.CreateRTChangeGroup(-1, ExecutionOrder, SessionId, SourceId, (int)ChangeStatus.ChangeCreationInProgress, false); m_runTimeChangeGroup.Owner = Owner; m_runTimeChangeGroup.Comment = Comment; m_runTimeChangeGroup.RevisionTime = RevisionTime; m_runTimeChangeGroup.StartTime = DateTime.UtcNow; m_runTimeChangeGroup.Name = Name; m_runTimeChangeGroup.ReflectedChangeGroupId = ReflectedChangeGroupId; m_runTimeChangeGroup.UsePagedActions = m_usePagedActions; // establish SessionRun association m_runTimeChangeGroup.SessionRun = manager.RuntimeSessionRun; // estabilish MigrationSource association m_runTimeChangeGroup.SourceSideMigrationSource = manager.RunTimeMigrationSource; // save the group context.AddToRTChangeGroupSet(m_runTimeChangeGroup); context.TrySaveChanges(); // record internal Id this.ChangeGroupId = m_runTimeChangeGroup.Id; } finally { context.Detach(m_runTimeChangeGroup); context.Detach(manager.RunTimeMigrationSource); context.Detach(manager.RuntimeSessionRun); } } }