Exemple #1
0
 // Methods
 internal MappedAssociation(MappedDataMember mm, AssociationMapping assocMap)
 {
     this.thisMember = mm;
     this.assocMap   = assocMap;
     this.Init();
     this.InitOther();
     if (((this.thisKey.Count != this.otherKey.Count) && (this.thisKey.Count > 0)) && (this.otherKey.Count > 0))
     {
         throw Error.MismatchedThisKeyOtherKey(this.thisMember.Name, this.thisMember.DeclaringType.Name);
     }
 }
 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);
     }
 }
Exemple #3
0
        private static AssociationMapping ReadAssociationMapping(XmlReader reader)
        {
            if (!IsInNamespace(reader) || (reader.LocalName != "Association"))
            {
                throw Error.UnexpectedElement("Association", string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", new object[] { reader.Prefix, string.IsNullOrEmpty(reader.Prefix) ? "" : "/", reader.LocalName }));
            }
            ValidateAttributes(reader, new string[] { "Name", "IsForeignKey", "IsUnique", "Member", "OtherKey", "Storage", "ThisKey", "DeleteRule", "DeleteOnNull" });
            AssociationMapping mapping = new AssociationMapping();

            mapping.DbName            = OptionalAttribute(reader, "Name");
            mapping.IsForeignKey      = OptionalBoolAttribute(reader, "IsForeignKey", false);
            mapping.IsUnique          = OptionalBoolAttribute(reader, "IsUnique", false);
            mapping.MemberName        = RequiredAttribute(reader, "Member");
            mapping.OtherKey          = OptionalAttribute(reader, "OtherKey");
            mapping.StorageMemberName = OptionalAttribute(reader, "Storage");
            mapping.ThisKey           = OptionalAttribute(reader, "ThisKey");
            mapping.DeleteRule        = OptionalAttribute(reader, "DeleteRule");
            mapping.DeleteOnNull      = OptionalBoolAttribute(reader, "DeleteOnNull", false);
            AssertEmptyElement(reader);
            return(mapping);
        }
Exemple #4
0
        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);
        }