我已经为我的一些实体类实现了一个接口:
public partial class Order : IReportable
{
public string TableName { get { return "Order"; } }
}
public partial class Client: IReportable
{
public string TableName { get { return "Client"; } }
}
public interface IReportable
{
string TableName { get; }
}
接下来,我将其添加到 DbContext 中:
public virtual DbSet<IReportable> IReportable { get; set; }
当我尝试查询实现此接口的所有表(如下所示)时:
var result = from reportabletable in db.IReportable
where reportabletable.TableName == table_name
select reportabletable
我遇到了以下异常:
“Report.DataAccess.IReportable”类型未映射。请检查该类型是否已通过使用Ignore方法或NotMappedAttribute数据注释明确排除。请验证该类型被定义为类,不是基元或泛型,并且不继承自EntityObject。