private IEnumerable <ChangeGroup> GetChangeGroupTablePageByStatus( int pageNumber, int pageSize, Guid sessionUniqueId, ChangeStatus status, bool useOtherSideMigrationItemSerializers, bool includeGroupInBacklog) { List <ChangeGroup> deltaTableEntries = new List <ChangeGroup>(); using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { int statusVal = (int)status; IQueryable <RTChangeGroup> query; if (includeGroupInBacklog) { query = (from cg in context.RTChangeGroupSet where cg.SessionUniqueId.Equals(sessionUniqueId) && cg.SourceUniqueId.Equals(SourceId) && cg.Status == statusVal orderby cg.Id select cg).Skip(pageNumber * pageSize).Take(pageSize); } else { query = (from cg in context.RTChangeGroupSet where cg.SessionUniqueId.Equals(sessionUniqueId) && cg.SourceUniqueId.Equals(SourceId) && cg.Status == statusVal && !cg.ContainsBackloggedAction orderby cg.Id select cg).Skip(pageNumber * pageSize).Take(pageSize); } foreach (RTChangeGroup rtChangeGroup in query) { SqlChangeGroup changeGroup = new SqlChangeGroup(this); changeGroup.UseOtherSideMigrationItemSerializers = useOtherSideMigrationItemSerializers; changeGroup.RealizeFromEDM(rtChangeGroup); deltaTableEntries.Add(changeGroup); } } return(deltaTableEntries); }
/// <summary> /// Discard a migration instruction change group and reactivate the corresponding delta table entry /// </summary> /// <param name="migrationInstructionEntry"></param> /// <returns>The corresponding delta table entry</returns> internal override ChangeGroup DiscardMigrationInstructionAndReactivateDelta(ChangeGroup migrationInstructionEntry) { Debug.Assert(migrationInstructionEntry.ReflectedChangeGroupId.HasValue, "migrationInstructionEntry.ReflectedChangeGroupId does not have value"); RTChangeGroup rtChangeGroup = null; using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { long migrInstrId = migrationInstructionEntry.ChangeGroupId; var migrInstr = context.RTChangeGroupSet.Where(g => g.Id == migrInstrId); long deltaId = migrationInstructionEntry.ReflectedChangeGroupId.Value; var delta = context.RTChangeGroupSet.Where(g => g.Id == deltaId); if (migrInstr.Count() != 1 || delta.Count() != 1) { return(null); } migrInstr.First().Status = (int)ChangeStatus.Obsolete; rtChangeGroup = delta.First(); rtChangeGroup.Status = (int)ChangeStatus.DeltaPending; context.TrySaveChanges(); context.Detach(rtChangeGroup); } SqlChangeGroup changeGroup = new SqlChangeGroup(this); changeGroup.UseOtherSideMigrationItemSerializers = true; changeGroup.RealizeFromEDM(rtChangeGroup); return(changeGroup); }
public override IEnumerable <ChangeGroup> NextMigrationInstructionTablePage( int pageNumber, int pageSize, bool isInConflictDetectionState, bool includeGroupInBacklog) { Guid sessionUniqueId = new Guid(Session.SessionUniqueId); int pendingDetection = (int)ChangeStatus.PendingConflictDetection; int pending = (int)ChangeStatus.Pending; List <ChangeGroup> deltaTableEntries = new List <ChangeGroup>(); using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { IQueryable <RTChangeGroup> query; if (includeGroupInBacklog) { if (isInConflictDetectionState) { query = (from cg in context.RTChangeGroupSet where cg.SessionUniqueId.Equals(sessionUniqueId) && cg.SourceUniqueId.Equals(SourceId) && (cg.Status == pendingDetection || cg.Status == pending) orderby cg.Id select cg).Skip(pageNumber * pageSize).Take(pageSize); } else { query = (from cg in context.RTChangeGroupSet where cg.SessionUniqueId.Equals(sessionUniqueId) && cg.SourceUniqueId.Equals(SourceId) && cg.Status == pending orderby cg.Id select cg).Skip(pageNumber * pageSize).Take(pageSize); } } else { if (isInConflictDetectionState) { query = (from cg in context.RTChangeGroupSet where cg.SessionUniqueId.Equals(sessionUniqueId) && cg.SourceUniqueId.Equals(SourceId) && (cg.Status == pendingDetection || cg.Status == pending) && !cg.ContainsBackloggedAction orderby cg.Id select cg).Skip(pageNumber * pageSize).Take(pageSize); } else { query = (from cg in context.RTChangeGroupSet where cg.SessionUniqueId.Equals(sessionUniqueId) && cg.SourceUniqueId.Equals(SourceId) && cg.Status == pending && !cg.ContainsBackloggedAction orderby cg.Id select cg).Skip(pageNumber * pageSize).Take(pageSize); } } foreach (RTChangeGroup rtChangeGroup in query) { SqlChangeGroup changeGroup = new SqlChangeGroup(this); changeGroup.UseOtherSideMigrationItemSerializers = true; changeGroup.RealizeFromEDM(rtChangeGroup); deltaTableEntries.Add(changeGroup); } } return(deltaTableEntries); }