C# EF6异常:DbExpressionBinding需要具有集合ResultType的输入表达式
运行此查询(使用LinqPad进行调试)时遇到异常: 我已经用相同的标题搜索了SO问题,但是我的包含列表是简单的数组,所以我不知道是什么导致了异常 非常感谢您的指点 更新C# EF6异常:DbExpressionBinding需要具有集合ResultType的输入表达式,c#,entity-framework-6,C#,Entity Framework 6,运行此查询(使用LinqPad进行调试)时遇到异常: 我已经用相同的标题搜索了SO问题,但是我的包含列表是简单的数组,所以我不知道是什么导致了异常 非常感谢您的指点 更新 public partial class BILL_INFO_DETAIL : DA.Services.IBS.Data.EntityFramework.Helper.IBaseEntity { public string BILL_NO { get; set; } public byte PAY_MODE_I
public partial class BILL_INFO_DETAIL : DA.Services.IBS.Data.EntityFramework.Helper.IBaseEntity
{
public string BILL_NO { get; set; }
public byte PAY_MODE_ID { get; set; }
public int CASHIER_NO { get; set; }
public int SERVICE_CODE { get; set; }
public Nullable<int> REQUESTED_QTY { get; set; }
public Nullable<int> CURRENT_QTY { get; set; }
public Nullable<decimal> FEE { get; set; }
public Nullable<decimal> ITEM_TOTAL { get; set; }
public Nullable<decimal> VAT_AMOUNT { get; set; }
public string USER_ID { get; set; }
public Nullable<int> BUSINESS_USER_ID { get; set; }
public Nullable<bool> INPUT_STATUS { get; set; }
public Nullable<System.DateTime> STAMP_DATE { get; set; }
public virtual BUSINESS_USER BUSINESS_USER { get; set; }
public virtual CASHIER CASHIER { get; set; }
public virtual PAY_MODE PAY_MODE { get; set; }
public virtual SERVICE_INFO SERVICE_INFO { get; set; }
}
我已尝试删除where和查询中的两个.Contains()
。实际上,只注释payModes.Contains(a.PAY\u MODE\u ID)
可以使查询工作
更新
public partial class BILL_INFO_DETAIL : DA.Services.IBS.Data.EntityFramework.Helper.IBaseEntity
{
public string BILL_NO { get; set; }
public byte PAY_MODE_ID { get; set; }
public int CASHIER_NO { get; set; }
public int SERVICE_CODE { get; set; }
public Nullable<int> REQUESTED_QTY { get; set; }
public Nullable<int> CURRENT_QTY { get; set; }
public Nullable<decimal> FEE { get; set; }
public Nullable<decimal> ITEM_TOTAL { get; set; }
public Nullable<decimal> VAT_AMOUNT { get; set; }
public string USER_ID { get; set; }
public Nullable<int> BUSINESS_USER_ID { get; set; }
public Nullable<bool> INPUT_STATUS { get; set; }
public Nullable<System.DateTime> STAMP_DATE { get; set; }
public virtual BUSINESS_USER BUSINESS_USER { get; set; }
public virtual CASHIER CASHIER { get; set; }
public virtual PAY_MODE PAY_MODE { get; set; }
public virtual SERVICE_INFO SERVICE_INFO { get; set; }
}
public分部类清单\u信息\u详细信息:DA.Services.IBS.Data.EntityFramework.Helper.IBaseEntity
{
公共字符串BILL_NO{get;set;}
公共字节PAY_MODE_ID{get;set;}
公共整数{get;set;}
公共int服务_代码{get;set;}
公共可为空的请求数量{get;set;}
公共可为空的当前_数量{get;set;}
公共可为空的费用{get;set;}
公共可空项_TOTAL{get;set;}
公共可空增值税金额{get;set;}
公共字符串用户_ID{get;set;}
公共可为空的业务用户ID{get;set;}
公共可空输入_状态{get;set;}
公共可为空的戳记_日期{get;set;}
公共虚拟业务\用户业务\用户{get;set;}
公共虚拟出纳出纳{get;set;}
公共虚拟支付模式支付模式{get;set;}
公共虚拟服务\u信息服务\u信息{get;set;}
}
当应用于字节
数组时,包含
方法转换似乎存在缺陷(在EF6.1.3和6.2中)(可能是因为通常字节数组用于表示二进制数据)
解决方法是使用int
数组:
var payModes = new int[] { 1, 2 };
或显式可枚举(以避免字节[]
特殊处理):
请注意,到enumerable的转换应该在查询表达式树之外,因为EF查询转换器无法识别
AsEnumerable()
调用,并且将生成NotSupportedException
您可以发布账单信息详细信息的模型吗?@Evk,我刚刚用模型更新了问题
var payModes = new byte[] { 1, 2 }.AsEnumerable();