Beispiel #1
0
 private void InitSpecialMember(MetaDataMember mm)
 {
     if ((mm.IsDbGenerated && mm.IsPrimaryKey) && string.IsNullOrEmpty(mm.Expression))
     {
         if (this.dbGeneratedIdentity != null)
         {
             throw Mapping.Error.TwoMembersMarkedAsPrimaryKeyAndDBGenerated(mm.Member, this.dbGeneratedIdentity.Member);
         }
         this.dbGeneratedIdentity = mm;
     }
     if (mm.IsPrimaryKey && !MappingSystem.IsSupportedIdentityType(mm.Type))
     {
         throw Mapping.Error.IdentityClrTypeNotSupported(mm.DeclaringType, mm.Name, mm.Type);
     }
     if (mm.IsVersion)
     {
         if (this.version != null)
         {
             throw Mapping.Error.TwoMembersMarkedAsRowVersion(mm.Member, this.version.Member);
         }
         this.version = mm;
     }
     if (mm.IsDiscriminator)
     {
         if (this.discriminator != null)
         {
             throw Mapping.Error.TwoMembersMarkedAsInheritanceDiscriminator(mm.Member, this.discriminator.Member);
         }
         this.discriminator = mm;
     }
 }
Beispiel #2
0
		private void InitSpecialMember(MetaDataMember mm)
		{
			// Can only have one auto gen member that is also an identity member,
			// except if that member is a computed column (since they are implicitly auto gen)
			if(mm.IsDbGenerated && mm.IsPrimaryKey && string.IsNullOrEmpty(mm.Expression))
			{
				if(this.dbGeneratedIdentity != null)
					throw Error.TwoMembersMarkedAsPrimaryKeyAndDBGenerated(mm.Member, this.dbGeneratedIdentity.Member);
				this.dbGeneratedIdentity = mm;
			}
			if(mm.IsPrimaryKey && !MappingSystem.IsSupportedIdentityType(mm.Type))
			{
				throw Error.IdentityClrTypeNotSupported(mm.DeclaringType, mm.Name, mm.Type);
			}
			if(mm.IsVersion)
			{
				if(this.version != null)
					throw Error.TwoMembersMarkedAsRowVersion(mm.Member, this.version.Member);
				this.version = mm;
			}
			if(mm.IsDiscriminator)
			{
				if(this.discriminator != null)
					throw Error.TwoMembersMarkedAsInheritanceDiscriminator(mm.Member, this.discriminator.Member);
				this.discriminator = mm;
			}
		}