示例#1
0
        public override ReadOnlyCollection <KeyValuePair <MigrationAction, MigrationAction> > DetectContentConflict()
        {
            List <KeyValuePair <MigrationAction, MigrationAction> > conflictActions = new List <KeyValuePair <MigrationAction, MigrationAction> >();
            Dictionary <long, SqlChangeGroup> loadedChangeGroups = new Dictionary <long, SqlChangeGroup>();

            using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
            {
                foreach (VCContentConflictResult contentConflictResults in context.QueryContentConflict(SourceId, new Guid(Session.SessionUniqueId)))
                {
                    RTChangeAction migrationInstructionAction =
                        context.RTChangeActionSet.Where(a => a.ChangeActionId == contentConflictResults.MigrationInstructionChangeActionId).First();

                    RTChangeAction deltaAction =
                        context.RTChangeActionSet.Where(a => a.ChangeActionId == contentConflictResults.DeltaChangeActionId).First();

                    SqlMigrationAction conflictActionSource = SqlMigrationAction.RealizeFromDB(migrationInstructionAction);
                    if (loadedChangeGroups.ContainsKey(migrationInstructionAction.ChangeGroupId))
                    {
                        conflictActionSource.ChangeGroup = loadedChangeGroups[migrationInstructionAction.ChangeGroupId];
                    }
                    else
                    {
                        RTChangeGroup  migrationInstructionChangeGroup = context.RTChangeGroupSet.Where(c => c.Id == migrationInstructionAction.ChangeGroupId).First();
                        SqlChangeGroup conflictChangeGroupSource       = new SqlChangeGroup(this);
                        conflictChangeGroupSource.RealizeFromEDMWithSingleAction(migrationInstructionChangeGroup, migrationInstructionAction);
                        loadedChangeGroups.Add(migrationInstructionAction.ChangeGroupId, conflictChangeGroupSource);
                        conflictActionSource.ChangeGroup = conflictChangeGroupSource;
                    }

                    SqlMigrationAction conflictActionTarget = SqlMigrationAction.RealizeFromDB(deltaAction);

                    if (loadedChangeGroups.ContainsKey(deltaAction.ChangeGroupId))
                    {
                        conflictActionTarget.ChangeGroup = loadedChangeGroups[deltaAction.ChangeGroupId];
                    }
                    else
                    {
                        RTChangeGroup  deltaChangeGroup          = context.RTChangeGroupSet.Where(c => c.Id == deltaAction.ChangeGroupId).First();
                        SqlChangeGroup conflictChangeGroupTarget = new SqlChangeGroup(this);
                        conflictChangeGroupTarget.RealizeFromEDMWithSingleAction(deltaChangeGroup, deltaAction);
                        loadedChangeGroups.Add(deltaAction.ChangeGroupId, conflictChangeGroupTarget);
                        conflictActionTarget.ChangeGroup = conflictChangeGroupTarget;
                    }

                    conflictActions.Add(new KeyValuePair <MigrationAction, MigrationAction>(conflictActionSource, conflictActionTarget));
                }
            }
            return(conflictActions.AsReadOnly());
        }