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; }
public void AssignFrom(AssociationItemSetting other) { this.PropertyName = other.PropertyName; this.OnOwnerRemove = other.OnOwnerRemove; this.OnTargetRemove = other.OnTargetRemove; this.table = other.table; this.TableUrn = other.TableUrn; this.Column = other.Column; this.PropertyType = other.PropertyType; }
public AssociationItemSetting Clone() { AssociationItemSetting cloned = new AssociationItemSetting(); cloned.PropertyName = this.PropertyName; cloned.OnOwnerRemove = this.OnOwnerRemove; cloned.OnTargetRemove = this.OnTargetRemove; cloned.table = this.table; cloned.TableUrn = this.TableUrn; cloned.Column = this.Column; cloned.PropertyType = this.PropertyType; return(cloned); }