【发布时间】:2015-11-27 03:24:35
【问题描述】:
我正在使用此处找到的过程 (Convert value when mapping) 通过封装转换映射属性的类型。就像@Mykroft 所说,这会阻止您针对数据库编写 LINQ 查询。
使用下面的示例属性,我如何告诉 Linq to Entities 在编写语句 db.Employee.Where(b => b.IsActive); 时使用 IsActiveBool ?
[Column("IsActive")]
protected string IsActiveBool { get; set; }
[System.ComponentModel.DataAnnotations.Schema.NotMapped]
public bool IsActive
{
get { return IsActiveBool == "Y"; }
set { IsActiveBool = value ? "Y" : "N"; }
}
【问题讨论】:
标签: c# linq entity-framework ef-code-first linq-to-entities