예제 #1
0
 // overload
 protected void CheckConcurrencyCheckConstraint(UpdateCommand <T> updateCommand)
 {
     CheckConcurrencyCheckConstraint(updateCommand.PropertyValues, updateCommand.ConcurrencySchema);
 }
예제 #2
0
 // in Execute(UpdateCommand<T>, Modifier<T>),Database.Modification.cs
 internal void CheckConstraints(UpdateCommand <T> updateCommand)
 {
     CheckConcurrencyCheckConstraint(updateCommand);
     CheckRelationshipConstraint(updateCommand);
 }
예제 #3
0
        internal protected void Split(IEnumerable <T> children, XElement childEntitySchema, ManyToManyRelationship manyToManyRelationship, Dictionary <string, object> parentPropertyValues, string childrenPath)
        {
            string childEntity = childEntitySchema.Attribute(SchemaVocab.Name).Value;

            XElement mmKeySchema         = TransKeySchema(manyToManyRelationship, out XElement mmEntitySchema);
            string   mmEntity            = mmEntitySchema.Attribute(SchemaVocab.Name).Value;
            XElement mmConcurrencySchema = GetConcurrencySchema(mmEntitySchema);

            //
            bool mmDeleteTransSetNull = IsDeleteTransSetNull(manyToManyRelationship);

            Dictionary <string, object>      mmUpdatePropertyValues = null;
            IEnumerable <DirectRelationship> mmRelationships        = null;

            if (mmDeleteTransSetNull)
            {
                mmUpdatePropertyValues = new Dictionary <string, object>();
                DirectRelationship oneToManyRelationship = manyToManyRelationship.DirectRelationships[0];
                for (int i = 0; i < oneToManyRelationship.RelatedProperties.Length; i++)
                {
                    string relatedPropertyName = oneToManyRelationship.RelatedProperties[i];
                    mmUpdatePropertyValues.Add(relatedPropertyName, null);
                }
            }
            else
            {
                mmRelationships = GetDirectRelationships(mmEntity);
            }

            int index = 0;

            foreach (T child in children)
            {
                Dictionary <string, object> childPropertyValues = GetPropertyValues(child, childEntitySchema);
                Dictionary <string, object> mmPropertyValues    = TransPropertyValues(manyToManyRelationship, parentPropertyValues, childPropertyValues);

                ExecuteCommand <T> mmExecuteCommand;
                if (mmDeleteTransSetNull)
                {
                    UpdateCommand <T> mmUpdateCommand = CreateUpdateCommand(child, childEntity);
                    mmUpdateCommand.FixedUpdatePropertyValues = mmUpdatePropertyValues;
                    mmUpdateCommand.ConcurrencySchema         = mmConcurrencySchema;

                    mmExecuteCommand = mmUpdateCommand;
                }
                else
                {
                    DeleteCommand <T> mmDeleteCommand = CreateDeleteCommand(child, childEntity);
                    mmDeleteCommand.ConcurrencySchema  = mmConcurrencySchema;
                    mmDeleteCommand.ChildRelationships = mmRelationships;

                    mmExecuteCommand = mmDeleteCommand;
                }

                mmExecuteCommand.EntitySchema         = mmEntitySchema;
                mmExecuteCommand.UniqueKeySchema      = mmKeySchema;
                mmExecuteCommand.PropertyValues       = mmPropertyValues;
                mmExecuteCommand.ParentPropertyValues = parentPropertyValues;
                mmExecuteCommand.ParentRelationship   = manyToManyRelationship.DirectRelationships[0];
                mmExecuteCommand.Path = string.Format("{0}[{1}]", childrenPath, index);

                Commands.Add(mmExecuteCommand);

                index++;
            }
        }