如何获得物业的长度?

时间:2014-03-03 14:15:50

标签: .net entity-framework-5

我正在使用实体框架代码First Approach,所以我有如下所示的映射模型。就像我有40个模型现在我想知道如上所示的BC_ID列的长度,如上所示。如何获得最大列长度?我想我们可以使用Reflection类来完成它,但不知道该怎么做。我正在使用Entity Framework 5.0

public class BusinessContactMap : EntityTypeConfiguration<BusinessContact>
    {
        public BusinessContactMap()
        {
            // Primary Key
            this.HasKey(t => t.BC_ID);

            // Properties
            this.Property(t => t.BC_ID)
                .IsRequired()
                .HasMaxLength(64);

            this.Property(t => t.BC_FirstName)
                .HasMaxLength(64);

            this.Property(t => t.BC_LastName)
                .HasMaxLength(64);

            this.Property(t => t.BC_Mobile)
                .HasMaxLength(64);

            this.Property(t => t.BC_Office)
                .HasMaxLength(64);

            this.Property(t => t.BC_Mail)
                .HasMaxLength(64);

            // Table & Column Mappings
            this.ToTable("BusinessContacts");
            this.Property(t => t.BC_ID).HasColumnName("BC_ID");
            this.Property(t => t.BC_FirstName).HasColumnName("BC_FirstName");
            this.Property(t => t.BC_LastName).HasColumnName("BC_LastName");
            this.Property(t => t.BC_Mobile).HasColumnName("BC_Mobile");
            this.Property(t => t.BC_Office).HasColumnName("BC_Office");
            this.Property(t => t.BC_Mail).HasColumnName("BC_Mail");
            this.Property(t => t.Record_Instance).HasColumnName("Record_Instance");
            this.Property(t =>t.Record_LastModified).HasColumnName("Record_LastModified");
        }
    }

0 个答案:

没有答案