/// <summary> /// Creates an instance of <see cref="EntityAssociation"/>. /// </summary> /// <param name="genParams">Parameters for the generation of DTOs.</param> public EntityAssociation(XElement associationNode, EntityAssociationEnd entityAssociationEndDesired, GenerateDTOsParams genParams) { // Set Association Name this.AssociationName = associationNode.Attribute(EdmxNodeAttributes.Association_Name).Value; // Get End nodes XElement[] endNodes = associationNode.DescendantsCSDL(EdmxNodes.End).ToArray(); // Get the position of the desired End node int endPosition = (entityAssociationEndDesired == EntityAssociationEnd.First ? 0 : 1); // Set DTO Name this.EntityName = endNodes[endPosition].Attribute(EdmxNodeAttributes.End_Type).Value; string[] entityNameSplitted = this.EntityName.Split(new string[] { Resources.Dot }, StringSplitOptions.RemoveEmptyEntries); this.EntityName = entityNameSplitted[(entityNameSplitted.Length - 1)]; this.DTOName = Utils.ConstructDTOName(this.EntityName, genParams); // Set End Role Name this.EndRoleName = endNodes[endPosition].Attribute(EdmxNodeAttributes.End_Role).Value; // Set Multiplicity this.EndMultiplicity = EntityAssociationHelper.GetMultiplicity(endNodes[endPosition]); }
/// <summary> /// Creates an instance of <see cref="EntityAssociation"/>. /// </summary> /// <param name="genParams">Parameters for the generation of DTOs.</param> public EntityAssociation(XElement associationNode, EntityAssociationEnd entityAssociationEndDesired, GenerateDTOsParams genParams) { // Set Association Name this.AssociationName = associationNode.Attribute(EdmxNodeAttributes.Association_Name).Value; // Get End nodes XElement[] endNodes = associationNode.DescendantsCSDL(EdmxNodes.End).ToArray(); // Get the position of the desired End node int endPosition = (entityAssociationEndDesired == EntityAssociationEnd.First ? 0 : 1); // Set DTO Name this.EntityName = endNodes[endPosition].Attribute(EdmxNodeAttributes.End_Type).Value; string[] entityNameSplitted = this.EntityName.Split(new string[] { Resources.Dot }, StringSplitOptions.RemoveEmptyEntries); this.EntityName = entityNameSplitted[(entityNameSplitted.Length - 1)]; this.DTOName = Utils.ConstructDTOName(this.EntityName, genParams); // Set End Role Name this.EndRoleName = endNodes[endPosition].Attribute(EdmxNodeAttributes.End_Role).Value; // Set Multiplicity this.EndMultiplicity = EntityAssociationHelper.GetMultiplicity(endNodes[endPosition]); }