internal StoreAssociationSet(EDMXFile parentFile, StorageModel storageModel, string name, StoreEntitySet fromES, StoreEntitySet toES, StoreEntityType fromET, StoreEntityType toET, string fromRoleName, string toRoleName, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, List<Tuple<StoreMemberProperty, StoreMemberProperty>> keys) : base(parentFile) { _storageModel = storageModel; _associationSetElement = CreateAssociationSet(); _associationElement = CreateAssociation(name); Name = name; FromRoleName = fromRoleName; ToRoleName = toRoleName; FromEntitySet = fromES; FromEntityType = fromET; FromMultiplicity = fromMultiplicity; ToEntitySet = toES; ToEntityType = toET; ToMultiplicity = toMultiplicity; foreach (Tuple<StoreMemberProperty, StoreMemberProperty> key in keys) { AddKey(key.Item1, key.Item2); } _keysEnumerated = true; }
internal StoreAssociationSet(EDMXFile parentFile, StorageModel storageModel, string name, StoreEntitySet fromES, StoreEntitySet toES, StoreEntityType fromET, StoreEntityType toET, string fromRoleName, string toRoleName, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, List <Tuple <StoreMemberProperty, StoreMemberProperty> > keys) : base(parentFile) { _storageModel = storageModel; _associationSetElement = CreateAssociationSet(); _associationElement = CreateAssociation(name); Name = name; FromRoleName = fromRoleName; ToRoleName = toRoleName; FromEntitySet = fromES; FromEntityType = fromET; FromMultiplicity = fromMultiplicity; ToEntitySet = toES; ToEntityType = toET; ToMultiplicity = toMultiplicity; foreach (Tuple <StoreMemberProperty, StoreMemberProperty> key in keys) { AddKey(key.Item1, key.Item2); } _keysEnumerated = true; }
internal static void SetMultiplicity(XmlElement endElement, MultiplicityTypeEnum multiplicity) { switch (multiplicity) { case MultiplicityTypeEnum.ZeroOrOne: endElement.SetAttribute("Multiplicity", "0..1"); break; case MultiplicityTypeEnum.One: endElement.SetAttribute("Multiplicity", "1"); break; default: endElement.SetAttribute("Multiplicity", "*"); break; } }
internal ModelAssociationSet(EDMXFile parentFile, ConceptualModel conceptualModel, string name, ModelEntitySet fromES, ModelEntitySet toES, ModelEntityType fromET, ModelEntityType toET, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, string fromNavProperty, string toNavProperty, List <Tuple <ModelMemberProperty, ModelMemberProperty> > keys) : base(parentFile) { _conceptualModel = conceptualModel; bool manyToMany = (fromMultiplicity == MultiplicityTypeEnum.Many && toMultiplicity == MultiplicityTypeEnum.Many); _associationSetElement = CreateAssociationSet(); _associationElement = CreateAssociation(name, manyToMany); Name = name; //set from/to sets and multiplicity FromEntitySet = fromES; FromEntityType = fromET; FromMultiplicity = fromMultiplicity; ToEntitySet = toES; ToEntityType = toET; ToMultiplicity = toMultiplicity; //add navigation properties if (!string.IsNullOrEmpty(fromNavProperty)) { fromET.AddNavigationMember(fromNavProperty, this, FromRoleName, ToRoleName); } if (!string.IsNullOrEmpty(toNavProperty)) { toET.AddNavigationMember(toNavProperty, this, ToRoleName, FromRoleName); } if (keys != null) { foreach (Tuple <ModelMemberProperty, ModelMemberProperty> key in keys) { AddKey(key.Item1, key.Item2); } } _keysEnumerated = true; }
internal ModelAssociationSet(EDMXFile parentFile, ConceptualModel conceptualModel, string name, ModelEntitySet fromES, ModelEntitySet toES, ModelEntityType fromET, ModelEntityType toET, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, string fromNavProperty, string toNavProperty, List<Tuple<ModelMemberProperty, ModelMemberProperty>> keys) : base(parentFile) { _conceptualModel = conceptualModel; bool manyToMany = (fromMultiplicity == MultiplicityTypeEnum.Many && toMultiplicity == MultiplicityTypeEnum.Many); _associationSetElement = CreateAssociationSet(); _associationElement = CreateAssociation(name, manyToMany); Name = name; //set from/to sets and multiplicity FromEntitySet = fromES; FromEntityType = fromET; FromMultiplicity = fromMultiplicity; ToEntitySet = toES; ToEntityType = toET; ToMultiplicity = toMultiplicity; //add navigation properties if (!string.IsNullOrEmpty(fromNavProperty)) { fromET.AddNavigationMember(fromNavProperty, this, FromRoleName, ToRoleName); } if (!string.IsNullOrEmpty(toNavProperty)) { toET.AddNavigationMember(toNavProperty, this, ToRoleName, FromRoleName); } if (keys != null) { foreach (Tuple<ModelMemberProperty, ModelMemberProperty> key in keys) { AddKey(key.Item1, key.Item2); } } _keysEnumerated = true; }
internal static MultiplicityTypeEnum GetMultiplicity(XmlElement endElement) { MultiplicityTypeEnum multiplicity = MultiplicityTypeEnum.Unknown; if (endElement != null) { switch (endElement.GetAttribute("Multiplicity")) { case "0..1": multiplicity = MultiplicityTypeEnum.ZeroOrOne; break; case "1": multiplicity = MultiplicityTypeEnum.One; break; default: multiplicity = MultiplicityTypeEnum.Many; break; } } return(multiplicity); }
/// <summary> /// Adds a new association between two store entitysets. /// </summary> /// <param name="name">Name of the association, typically the foreign key name.</param> /// <param name="fromEntitySet">From-entityset.</param> /// <param name="toEntitySet">To-entityset.</param> /// <param name="fromEntityType">From-entitytype. This must be an entity type associated with the from-entityset, or part of the same inheritance structure.</param> /// <param name="toEntityType">To-entitytype. This must be an entity type associated with the to-entityset, or part of the same inheritance structure.</param> /// <param name="fromRoleName">From-role</param> /// <param name="toRoleName">To-role</param> /// <param name="fromMultiplicity">From-multiplicity.</param> /// <param name="toMultiplicity">To-multiplicity.</param> /// <param name="keys">Pairs of the foreign key / association scalar members enforcing the association/foreign key constraint.</param> /// <returns></returns> public StoreAssociationSet AddAssociation(string name, StoreEntitySet fromEntitySet, StoreEntitySet toEntitySet, StoreEntityType fromEntityType, StoreEntityType toEntityType, string fromRoleName, string toRoleName, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, List <Tuple <StoreMemberProperty, StoreMemberProperty> > keys) { if (!AssociationSets.Where(et => et.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)).Any()) { StoreAssociationSet sas = new StoreAssociationSet(this.ParentFile, this, name, fromEntitySet, toEntitySet, fromEntityType, toEntityType, fromRoleName, toRoleName, fromMultiplicity, toMultiplicity, keys); _storeAssociationSets.Add(sas.Name, sas); sas.NameChanged += new EventHandler <NameChangeArgs>(aset_NameChanged); sas.Removed += new EventHandler(aset_Removed); return(sas); } else { throw new ArgumentException("An association named " + name + " already exists in the model."); } }
/// <summary> /// Adds a new association between two store entitysets. /// </summary> /// <param name="name">Name of the association, typically the foreign key name.</param> /// <param name="fromEntitySet">From-entityset.</param> /// <param name="toEntitySet">To-entityset.</param> /// <param name="fromMultiplicity">From-multiplicity.</param> /// <param name="toMultiplicity">To-multiplicity.</param> /// <param name="keys">Pairs of the foreign key / association scalar members enforcing the association/foreign key constraint.</param> /// <returns>A new StoreAssociationSet object.</returns> public StoreAssociationSet AddAssociation(string name, StoreEntitySet fromEntitySet, StoreEntitySet toEntitySet, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, List <Tuple <StoreMemberProperty, StoreMemberProperty> > keys) { return(AddAssociation(name, fromEntitySet, toEntitySet, fromEntitySet.EntityType, toEntitySet.EntityType, fromEntitySet.EntityType.Name, toEntitySet.EntityType.Name, fromMultiplicity, toMultiplicity, keys)); }
/// <summary> /// Adds a new association between two store entitysets. /// </summary> /// <param name="name">Name of the association, typically the foreign key name.</param> /// <param name="fromEntitySet">From-entityset.</param> /// <param name="toEntitySet">To-entityset.</param> /// <param name="fromEntityType">From-entitytype. This must be an entity type associated with the from-entityset, or part of the same inheritance structure.</param> /// <param name="toEntityType">To-entitytype. This must be an entity type associated with the to-entityset, or part of the same inheritance structure.</param> /// <param name="fromRoleName">From-role</param> /// <param name="toRoleName">To-role</param> /// <param name="fromMultiplicity">From-multiplicity.</param> /// <param name="toMultiplicity">To-multiplicity.</param> /// <param name="keys">Pairs of the foreign key / association scalar members enforcing the association/foreign key constraint.</param> /// <returns></returns> public StoreAssociationSet AddAssociation(string name, StoreEntitySet fromEntitySet, StoreEntitySet toEntitySet, StoreEntityType fromEntityType, StoreEntityType toEntityType, string fromRoleName, string toRoleName, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, List<Tuple<StoreMemberProperty, StoreMemberProperty>> keys) { if (!AssociationSets.Where(et => et.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)).Any()) { StoreAssociationSet sas = new StoreAssociationSet(this.ParentFile, this, name, fromEntitySet, toEntitySet, fromEntityType, toEntityType, fromRoleName, toRoleName, fromMultiplicity, toMultiplicity, keys); _storeAssociationSets.Add(sas.Name, sas); sas.NameChanged += new EventHandler<NameChangeArgs>(aset_NameChanged); sas.Removed += new EventHandler(aset_Removed); return sas; } else { throw new ArgumentException("An association named " + name + " already exists in the model."); } }
/// <summary> /// Adds a new association between two store entitysets. /// </summary> /// <param name="name">Name of the association, typically the foreign key name.</param> /// <param name="fromEntitySet">From-entityset.</param> /// <param name="toEntitySet">To-entityset.</param> /// <param name="fromMultiplicity">From-multiplicity.</param> /// <param name="toMultiplicity">To-multiplicity.</param> /// <param name="keys">Pairs of the foreign key / association scalar members enforcing the association/foreign key constraint.</param> /// <returns>A new StoreAssociationSet object.</returns> public StoreAssociationSet AddAssociation(string name, StoreEntitySet fromEntitySet, StoreEntitySet toEntitySet, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, List<Tuple<StoreMemberProperty, StoreMemberProperty>> keys) { return AddAssociation(name, fromEntitySet, toEntitySet, fromEntitySet.EntityType, toEntitySet.EntityType, fromEntitySet.EntityType.Name, toEntitySet.EntityType.Name, fromMultiplicity, toMultiplicity, keys); }
/// <summary> /// Adds a new association set and association between two conceptual model entities. /// </summary> /// <param name="name">Name of the association and association set.</param> /// <param name="fromEntitySet">Entity set where the entity set originates from. For one-to-many associations, this is typically the many-side of the association.</param> /// <param name="toEntitySet">Entity set that the entity set references.</param> /// <param name="fromEntityType">Entity type that the association originates from. This should be the entity type or a descendant of the entity type for the entity set passed in the fromEntitySet parameter.</param> /// <param name="toEntityType">Entity type that the association references. This should be the entity type or a descendant of the entity type that the entity set passed in the toEntitySet parameter.</param> /// <param name="fromMultiplicity">Multiplicity for the from entity set.</param> /// <param name="toMultiplicity">Multiplicity for the to entity set.</param> /// <param name="fromNavigationProperty">Name for the conceptual model navigation property in the fromEntityType for the association.</param> /// <param name="toNavigationProperty">Name for the conceptual model navigation property in the toEntityType for the association.</param> /// <param name="keys">A list of the entity key pairs for the association. This is a list containing pairs of ModelMemberProperty instances from the From and To entity types.</param> /// <returns></returns> public ModelAssociationSet AddAssociation(string name, ModelEntitySet fromEntitySet, ModelEntitySet toEntitySet, ModelEntityType fromEntityType, ModelEntityType toEntityType, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, string fromNavigationProperty, string toNavigationProperty, List<Tuple<ModelMemberProperty, ModelMemberProperty>> keys) { try { if (!AssociationSets.Where(et => et.Name == name).Any()) { ModelAssociationSet mas = new ModelAssociationSet(this.ParentFile, this, name, fromEntitySet, toEntitySet, fromEntityType, toEntityType, fromMultiplicity, toMultiplicity, fromNavigationProperty, toNavigationProperty, keys); _modelAssociationSets.Add(mas.Name, mas); mas.NameChanged += new EventHandler<NameChangeArgs>(aset_NameChanged); mas.Removed += new EventHandler(aset_Removed); return mas; } else { throw new ArgumentException("An association named " + name + " already exists in the model."); } } catch (Exception ex) { try { if (!ex.Data.Contains("EDMXType")) { ex.Data.Add("EDMXType", this.GetType().Name); } if (!ex.Data.Contains("EDMXObjectName")) { ex.Data.Add("EDMXObjectName", this.ContainerName); } } catch { } throw; } }
/// <summary> /// Adds a new association set and association between two conceptual model entities. /// </summary> /// <param name="name">Name of the association and association set.</param> /// <param name="fromEntitySet">Entity set where the entity set originates from. For one-to-many associations, this is typically the many-side of the association.</param> /// <param name="toEntitySet">Entity set that the entity set references.</param> /// <param name="fromEntityType">Entity type that the association originates from. This should be the entity type or a descendant of the entity type for the entity set passed in the fromEntitySet parameter.</param> /// <param name="toEntityType">Entity type that the association references. This should be the entity type or a descendant of the entity type that the entity set passed in the toEntitySet parameter.</param> /// <param name="fromMultiplicity">Multiplicity for the from entity set.</param> /// <param name="toMultiplicity">Multiplicity for the to entity set.</param> /// <param name="fromNavigationProperty">Name for the conceptual model navigation property in the fromEntityType for the association.</param> /// <param name="toNavigationProperty">Name for the conceptual model navigation property in the toEntityType for the association.</param> /// <param name="keys">A list of the entity key pairs for the association. This is a list containing pairs of ModelMemberProperty instances from the From and To entity types.</param> /// <returns></returns> public ModelAssociationSet AddAssociation(string name, ModelEntitySet fromEntitySet, ModelEntitySet toEntitySet, ModelEntityType fromEntityType, ModelEntityType toEntityType, MultiplicityTypeEnum fromMultiplicity, MultiplicityTypeEnum toMultiplicity, string fromNavigationProperty, string toNavigationProperty, List <Tuple <ModelMemberProperty, ModelMemberProperty> > keys) { try { if (!AssociationSets.Where(et => et.Name == name).Any()) { ModelAssociationSet mas = new ModelAssociationSet(this.ParentFile, this, name, fromEntitySet, toEntitySet, fromEntityType, toEntityType, fromMultiplicity, toMultiplicity, fromNavigationProperty, toNavigationProperty, keys); _modelAssociationSets.Add(mas.Name, mas); mas.NameChanged += new EventHandler <NameChangeArgs>(aset_NameChanged); mas.Removed += new EventHandler(aset_Removed); return(mas); } else { throw new ArgumentException("An association named " + name + " already exists in the model."); } } catch (Exception ex) { try { if (!ex.Data.Contains("EDMXType")) { ex.Data.Add("EDMXType", this.GetType().Name); } if (!ex.Data.Contains("EDMXObjectName")) { ex.Data.Add("EDMXObjectName", this.ContainerName); } } catch { } throw; } }
internal static void SetMultiplicity(XmlElement endElement, MultiplicityTypeEnum multiplicity) { switch (multiplicity) { case MultiplicityTypeEnum.ZeroOrOne: endElement.SetAttribute("Multiplicity", "0..1"); break; case MultiplicityTypeEnum.One: endElement.SetAttribute("Multiplicity", "1"); break; default: endElement.SetAttribute("Multiplicity", "*"); break; } }