基本オブジェクトのプロパティの中心的なマッピングを取得するにはいくつかのトリックがありますか? EntityTypeConfigurationを使用しているときに、抽象クラスの単純なパターンがありますか。
何かヒントありがとうございます。クラスに私は答えが、私はそれを割れて6時間後 How to create and use a generic class EntityTypeConfiguration<TEntity> と Dynamic way to Generate EntityTypeConfiguration : The type 'TResult' must be a non-nullable value typeEntityTypeConfigurationを使用する場合の抽象ドメインモデルの基本クラス<T>
public abstract class BosBaseObject
{
public virtual Guid Id { set; get; }
public virtual string ExternalKey { set; get; }
public byte[] RowVersion { get; set; }
}
public class News : BosBaseObject
{
public String Heading { set; get; }
}
public class NewsMap : EntityTypeConfiguration<News>
{
public NewsMap()
{
//Base Object Common Mappings
// How can we use a central mapping for all Base Abstract properties
}
}
// Something like this but very open to any suggestion....
public class BosBaseEntityConfig<T> : EntityTypeConfiguration<T>
{
public void BaseObjectMap()
{
// Primary Key
this.HasKey(t => t.Id);
// Properties
this.Property(t => t.Id).HasDatabaseGeneratedOption(databaseGeneratedOption: DatabaseGeneratedOption.None);
this.Property(t => t.RowVersion)
.IsRequired()
.IsFixedLength()
.HasMaxLength(8)
.IsRowVersion();
//Column Mappings
this.Property(t => t.Id).HasColumnName("Id");
}
}