【发布时间】:2014-02-11 15:55:47
【问题描述】:
我第一次做 EF 代码优先,我的实体有一个IDateRange 类型的属性它的定义是这样的:
public class PartyClassification
{
public IDateRange EffectiveDate { get; set; }
/*
other properties ...
*/
}
public interface IDateRange : IRange<DateTime>
{
}
public interface IRange<T>
{
T From { get; set; }
T To { get; set; }
}
我的所有其他属性都是简单的 clr 类型转换为 db 中的适当类型,但不是 EffectiveDate 。我希望 EffectiveDate 在 db 中的两个 DateTime 列中转换。
我想知道我是否可以通过custom convention 做到这一点,或者有更好的方法吗?
谢谢
【问题讨论】:
标签: c# entity-framework ef-code-first entity-framework-6