非标准继承映射我在我的DB(其中后人引用与外键基地)“表继承”,使用的LINQ to SQL作为我DAL:与AutoMapper
[Table]
class Document {
[Column]public int ID { get; set; }
[Column]public int DocTypeID { get; set; }
[Association]public Application Application { get; set; }
}
[Table]
class Application {
[Column]public int ID { get; set; }
[Column]public string AppType { get; set; }
[Association]public Document Document {get;set}
}
因为L2S不支持多表继承Application
不是从Document
继承。然而,在我的实体类我也想继承:
class DocumentBase {
public int ID { get; set; }
public int DocTypeID { get; set; }
}
class MyApplication : DocumentBase {
public string AppType { get; set; }
}
现在,我创建的映射:
Mapper.CreateMap<Document, DocumentBase>();
Mapper.CreateMap<Application, MyApplication>();
但AutoMapper抱怨没有映射在MyApplication
基本属性。我不想在MyApplication
地图中复制基本属性(太多的DocumentBase
后代)。我发现很少有帖子建议自定义ITypeConverter
,但不明白如何将其应用于我的场景。我该怎么办?
非常有趣,我以前没见过 – boca