का उपयोग करते समय सार डोमेन मॉडल बेस क्लास बेस ऑब्जेक्ट गुणों का केंद्रीय मैपिंग प्राप्त करने के लिए कुछ चाल है? EntityTypeConfiguration का उपयोग करते समय अमूर्त कक्षाओं के लिए कुछ सरल पैटर्न है।
किसी भी सुझाव की बहुत सराहना की। इम एक वर्गEntityTypeConfiguration <T>
Public class BaseEntityConfig<T> : EntityTypeConfiguration<T>
इसी तरह के मुद्दों घोषित करने के लिए, मैं जहां सके जवाब काम करने के लिए How to create and use a generic class EntityTypeConfiguration<TEntity> और Dynamic way to Generate EntityTypeConfiguration : The type 'TResult' must be a non-nullable value type
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");
}
}