private void InitOther() { if (this.otherType == null) { Type type = this.isMany ? TypeSystem.GetElementType(this.thisMember.Type) : this.thisMember.Type; this.otherType = this.thisMember.DeclaringType.Model.GetMetaType(type); this.otherKey = (this.assocMap.OtherKey != null) ? MetaAssociationImpl.MakeKeys(this.otherType, this.assocMap.OtherKey) : this.otherType.IdentityMembers; this.otherKeyIsPrimaryKey = MetaAssociationImpl.AreEqual(this.otherKey, this.otherType.IdentityMembers); foreach (MetaDataMember member in this.otherType.DataMembers) { if ((member.IsAssociation && (member != this.thisMember)) && (member.MappedName == this.thisMember.MappedName)) { this.otherMember = member; break; } } } }
private void Init() { this.isMany = TypeSystem.IsSequenceType(this.thisMember.Type); this.thisKey = (this.assocMap.ThisKey != null) ? MetaAssociationImpl.MakeKeys(this.thisMember.DeclaringType, this.assocMap.ThisKey) : this.thisMember.DeclaringType.IdentityMembers; this.thisKeyIsPrimaryKey = MetaAssociationImpl.AreEqual(this.thisKey, this.thisMember.DeclaringType.IdentityMembers); this.isForeignKey = this.assocMap.IsForeignKey; this.isNullable = true; foreach (MetaDataMember member in this.thisKey) { if (member == null) { throw Error.UnexpectedNull("MetaDataMember"); } if (!member.CanBeNull) { this.isNullable = false; break; } } if (this.assocMap.DeleteOnNull && ((!this.isForeignKey || this.isMany) || this.isNullable)) { throw Error.InvalidDeleteOnNullSpecification(this.thisMember); } }