Example #1
0
        public EntityBatchRelationship AssociateParent(string parentUniqueRelationshipName, RecordKeyType linkOn, List <string> childFieldNamesToMatchOn)
        {
            var relationship = new EntityBatchRelationship("ParentRel_" + Guid.NewGuid().ToString(), parentUniqueRelationshipName, linkOn, childFieldNamesToMatchOn);

            AssociateParent(relationship);

            return(relationship);
        }
Example #2
0
        public void AddAutoBindingForeignKey(string foreignKeyFieldToUpdate, int parentPrimaryKeyColumnIdx, string parentUniqueRelationshipName, RecordKeyType linkOn, List <string> childFieldNamesToMatchOn)
        {
            if (String.IsNullOrWhiteSpace(foreignKeyFieldToUpdate))
            {
                throw new Exception("Foreign key field to update is missing or empty.");
            }

            var foreignKeyRelationship = new EntityBatchRelationship("AutoBindingForeignKey_" + Guid.NewGuid().ToString(), parentUniqueRelationshipName, linkOn, childFieldNamesToMatchOn);

            AssociateParent(foreignKeyRelationship);

            AutoBindingForeignKeys.Add(new AutoBindingForeignKey(foreignKeyRelationship, foreignKeyFieldToUpdate, parentPrimaryKeyColumnIdx));
        }
Example #3
0
        public AutoBindingForeignKey(EntityBatchRelationship relationship, string fieldNameToUpdate, int parentPrimaryKeyColumnIdx)
        {
            if (relationship == null)
            {
                throw new Exception("Foreign key relationship can not be null");
            }

            if (String.IsNullOrWhiteSpace(fieldNameToUpdate))
            {
                throw new Exception("Field name to update is missing or empty.");
            }

            Relationship = relationship;

            FieldNameToUpdate = fieldNameToUpdate;

            ParentPrimaryKeyColumnIdx = parentPrimaryKeyColumnIdx;
        }
Example #4
0
        public void AssociateParent(EntityBatchRelationship relationship)
        {
            if (relationship == null)
            {
                throw new Exception("Relationship can not be null.");
            }

            if (Relationships.ContainsKey(relationship.Name))
            {
                throw new Exception(string.Format("A relationship with name '{0}' already exists.", relationship.Name));
            }

            Relationships.Add(relationship.Name, relationship);

            foreach (var childFieldName in relationship.ChildFieldNamesToMatchOn)
            {
                DataOnlyFields.Add(new DataOnlyField(childFieldName, isRequiredByJobBatch: false));
            }
        }