protected override void BuildTypeAttributes(List <IOrmAttribute> typeAttributes) { typeAttributes.Add(this.KeyAttribute); bool isSource = IsSourceWithinAssociation(); if (this.PersistentTypeHasAssociations != null) { IPersistentTypeHasAssociations associations = this.PersistentTypeHasAssociations; IAssociationInfo association = isSource ? associations.TargetAssociation : associations.SourceAssociation; typeAttributes.Add(association); } }
private void InternalPrefilter(IScalarProperty property, IOrmAttribute attribute, Dictionary <string, Defaultable> attributeGroupItems) { OrmFieldAttribute fieldAttribute = attribute as OrmFieldAttribute; if (fieldAttribute != null) { Prefilter(property, fieldAttribute, attributeGroupItems); } IAssociationInfo associationInfo = attribute as IAssociationInfo; if (associationInfo != null) { // No prefiltering at now... } }
public static IPersistentTypeHasAssociations CreatePersistentTypesAssociation(ModelElement sourceElement, ModelElement targetElement, IAssociationInfo sourceInfo, IAssociationInfo targetInfo, string associationName, bool createPropertyEnd1, bool createPropertyEnd2) { PersistentType sourceEntity = (PersistentType)sourceElement; PersistentType targetEntity = (PersistentType)targetElement; PersistentTypeHasAssociations typeAssociations = new PersistentTypeHasAssociations(sourceEntity, targetEntity); typeAssociations.End1.Multiplicity = sourceInfo.Multiplicity; typeAssociations.End1.OnOwnerRemove = sourceInfo.OnOwnerRemove; typeAssociations.End1.OnTargetRemove = sourceInfo.OnTargetRemove; typeAssociations.End1.UseAssociationAttribute = sourceInfo.UseAssociationAttribute; // association End2 values typeAssociations.End2.Multiplicity = targetInfo.Multiplicity; typeAssociations.End2.OnOwnerRemove = targetInfo.OnOwnerRemove; typeAssociations.End2.OnTargetRemove = targetInfo.OnTargetRemove; typeAssociations.End2.UseAssociationAttribute = targetInfo.UseAssociationAttribute; typeAssociations.Name = associationName; NavigationProperty sourceNavigationProperty = createPropertyEnd1 ? new NavigationProperty(sourceElement.Partition) : null; //bool isToSelfLookup = sourceInfo == targetInfo; //NavigationProperty targetNavigationProperty = isToSelfLookup ? null : new NavigationProperty(targetElement.Partition); NavigationProperty targetNavigationProperty = null; //if (!isToSelfLookup || !createPropertyEnd1) if (createPropertyEnd2) { targetNavigationProperty = new NavigationProperty(targetElement.Partition); } if (sourceNavigationProperty != null) { sourceNavigationProperty.PersistentTypeOfNavigationProperty = sourceEntity; sourceNavigationProperty.Name = sourceInfo.PairTo.Value; sourceNavigationProperty.Multiplicity = targetInfo.Multiplicity; sourceNavigationProperty.PersistentTypeHasAssociations = typeAssociations; } if (targetNavigationProperty != null) { targetNavigationProperty.PersistentTypeOfNavigationProperty = targetEntity; targetNavigationProperty.Name = targetInfo.PairTo.Value; targetNavigationProperty.Multiplicity = sourceInfo.Multiplicity; targetNavigationProperty.PersistentTypeHasAssociations = typeAssociations; } typeAssociations.End1.PairTo.SetAsCustom(createPropertyEnd1 ? sourceNavigationProperty.Name : targetNavigationProperty.Name); typeAssociations.End2.PairTo.SetAsCustom(createPropertyEnd2 ? targetNavigationProperty.Name : sourceNavigationProperty.Name); return(typeAssociations); }