internal MappedAssociation(MappedDataMember mm, AssociationMapping assocMap) { this.thisMember = mm; this.assocMap = assocMap; this.Init(); this.InitOther(); //validate the number of ThisKey columns is the same as the number of OtherKey columns if(this.thisKey.Count != this.otherKey.Count && this.thisKey.Count > 0 && this.otherKey.Count > 0) { throw Error.MismatchedThisKeyOtherKey(thisMember.Name, thisMember.DeclaringType.Name); } }
private static AssociationMapping ReadAssociationMapping(XmlReader reader) { System.Diagnostics.Debug.Assert(reader.NodeType == XmlNodeType.Element); if (!IsInNamespace(reader) || reader.LocalName != XmlMappingConstant.Association) { throw Error.UnexpectedElement(XmlMappingConstant.Association, String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}{1}{2}", reader.Prefix, String.IsNullOrEmpty(reader.Prefix) ? "" : "/", reader.LocalName)); } ValidateAttributes(reader, new[] { XmlMappingConstant.Name, XmlMappingConstant.IsForeignKey, XmlMappingConstant.IsUnique, XmlMappingConstant.Member, XmlMappingConstant.OtherKey, XmlMappingConstant.Storage, XmlMappingConstant.ThisKey, XmlMappingConstant.DeleteRule, XmlMappingConstant.DeleteOnNull, }); AssociationMapping am = new AssociationMapping(); am.DbName = OptionalAttribute(reader, XmlMappingConstant.Name); am.IsForeignKey = OptionalBoolAttribute(reader, XmlMappingConstant.IsForeignKey, false); am.IsUnique = OptionalBoolAttribute(reader, XmlMappingConstant.IsUnique, false); am.MemberName = RequiredAttribute(reader, XmlMappingConstant.Member); am.OtherKey = OptionalAttribute(reader, XmlMappingConstant.OtherKey); am.StorageMemberName = OptionalAttribute(reader, XmlMappingConstant.Storage); am.ThisKey = OptionalAttribute(reader, XmlMappingConstant.ThisKey); am.DeleteRule = OptionalAttribute(reader, XmlMappingConstant.DeleteRule); am.DeleteOnNull = OptionalBoolAttribute(reader, XmlMappingConstant.DeleteOnNull, false); AssertEmptyElement(reader); return am; }