Пример #1
0
        GenerateAssociationPropertyNames(AssocationType assocationType, AssociationItem associationItem)
        {
            string ownerPropertyName;
            AssociationPropertyType ownerPropertyType;
            string targetPropertyName;
            AssociationPropertyType targetPropertyType;

            if (assocationType == AssocationType.OneToOne)
            {
                //TODO: Generating property name - is OK ??
                //ownerPropertyName = NormalizeDBName(associationItem.ForeignKeyColumn.Owner.ForeignTable.Name);
                ownerPropertyName  = NormalizeDBName(associationItem.ForeignKeyColumn.Name ?? associationItem.ForeignKeyColumn.Owner.ForeignTable.Name);
                ownerPropertyType  = AssociationPropertyType.EntityReference;
                targetPropertyName = string.Empty;
                targetPropertyType = AssociationPropertyType.None;
            }
            else
            {
                if (assocationType == AssocationType.ManyToMany)
                {
                    ownerPropertyName  = BuildEntitySetPropertyName(NormalizeDBName(associationItem.TargetSetting.Table.Name));
                    targetPropertyName = BuildEntitySetPropertyName(NormalizeDBName(associationItem.OwnerSetting.Table.Name));
                    ownerPropertyType  = AssociationPropertyType.EntitySet;
                    targetPropertyType = AssociationPropertyType.EntitySet;
                }
                else
                {
                    ownerPropertyName  = BuildEntitySetPropertyName(NormalizeDBName(associationItem.TargetSetting.Table.Name));
                    ownerPropertyType  = AssociationPropertyType.EntitySet;
                    targetPropertyName = NormalizeDBName(associationItem.OwnerSetting.Table.Name);
                    targetPropertyType = AssociationPropertyType.EntityReference;
                }
            }

            return(new Tuple <string, AssociationPropertyType, string, AssociationPropertyType>(ownerPropertyName,
                                                                                                ownerPropertyType, targetPropertyName, targetPropertyType));
        }
Пример #2
0
        public AssociationItem(ForeignKeyColumn foreignKeyColumn, ForeignKeyColumn auxiliaryForeignKeyColumn, AssocationType assocationType)
        {
            this.Id = Guid.NewGuid();

            this.OwnerSetting  = new AssociationItemSetting();
            this.TargetSetting = new AssociationItemSetting();

            this.AssocationType = assocationType;

            this.ForeignKeyColumn          = foreignKeyColumn;
            this.AuxiliaryForeignKeyColumn = auxiliaryForeignKeyColumn;

            bool isAux = auxiliaryForeignKeyColumn != null;

            Table ownerTable = isAux ? (Table)foreignKeyColumn.Owner.ForeignTable :(Table)foreignKeyColumn.Owner.Owner;

            OwnerSetting.Table        = ownerTable;
            OwnerSetting.Column       = isAux ? foreignKeyColumn.ReferencedColumn : foreignKeyColumn.Name;
            OwnerSetting.PropertyType = isAux ? AssociationPropertyType.EntitySet : AssociationPropertyType.EntityReference;

            Table foreignTable = isAux ? auxiliaryForeignKeyColumn.Owner.ForeignTable : foreignKeyColumn.Owner.ForeignTable;

            TargetSetting.Table        = foreignTable;
            TargetSetting.Column       = isAux ? auxiliaryForeignKeyColumn.ReferencedColumn : foreignKeyColumn.ReferencedColumn;
            TargetSetting.PropertyType = isAux ? (assocationType == AssocationType.ManyToMany ? AssociationPropertyType.EntitySet : AssociationPropertyType.EntityReference) : AssociationPropertyType.EntityReference;
        }
Пример #3
0
 public AssociationItem(ForeignKeyColumn foreignKeyColumn, AssocationType assocationType)
     : this(foreignKeyColumn, null, assocationType)
 {
 }