- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在运行此查询时遇到异常(使用 LinqPad 进行调试):
int[] serviceCodes= new int[] { 1610, 1611, 1612 };
byte[] payModes = new byte[] { 1, 2 };
int[] months = new int[] { 10, 11, 12 };
int year = 2017;
using (var context = new FinanceConnection())
{
var result = from a in
(from a in context.BILL_INFO_DETAILS
where
a.INPUT_STATUS == true &&
serviceCodes.Contains(a.SERVICE_INFO.SERVICE_CODE) &&
payModes.Contains(a.PAY_MODE_ID) &&
a.STAMP_DATE != null &&
months.Contains(a.STAMP_DATE.Value.Month) &&
a.STAMP_DATE.Value.Year == year &&
a.SERVICE_INFO.FEE > 1
select new
{
a.REQUESTED_QTY,
a.ITEM_TOTAL,
Dummy = "x"
})
group a by new { a.Dummy }
into g
select new ViewGuessAlMajlisOffline
{
Transaction =
g.Sum(p => p.REQUESTED_QTY) == 0 ? (int?)null : (int)g.Sum(p => p.REQUESTED_QTY),
Income = g.Sum(p => p.ITEM_TOTAL) == 0
? (decimal?)null
: (decimal)g.Sum(p => p.ITEM_TOTAL)
};
result.Dump();
}
我搜索了具有相同标题的 SO 问题,但我的包含列表是简单的数组,所以我不知道究竟是什么导致了异常。
非常感谢任何指点。
更新
我已经尝试删除其中的两个 .Contains()
并且查询有效。实际上,仅注释 payModes.Contains(a.PAY_MODE_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; }
}
最佳答案
当应用于 byte
数组时,Contains
方法转换似乎存在错误(在 EF6.1.3 和 6.2 中)(可能是因为通常使用字节数组来表示二进制数据)。
解决方法是使用 int
数组:
var payModes = new int[] { 1, 2 };
或显式可枚举(避免byte[]
特殊处理):
var payModes = new byte[] { 1, 2 }.AsEnumerable();
请注意,向可枚举的转换应该在查询表达式树之外,因为 AsEnumerable()
调用无法被 EF 查询转换器识别并将生成 NotSupportedException
。
关于c# - EF6 异常 : DbExpressionBinding requires an input expression with a collection ResultType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49123858/
目录 mybatis resulttype 返回值异常 例如:resulttype = "student" 但是当中有些字段为空
我目前正在为两个数据库 API(领域和 Firestore)编写数据库访问类。为了精简代码,我尝试使用泛型(#1)来解决整个问题。不幸的是,它不起作用。我在哪里错过了重点? 我尝试定义关联类型(#2)
我刚刚遇到了通过 Xcode 4.6.2 中的模型编辑器创建的获取请求模板的问题。我尝试更改获取请求的核心数据检查器中的结果类型设置,如下图所示: 但是,当我在代码中加载模板时,这些设置没有反射(re
我想按列对表进行分组并获取计数,然后使用结果创建字典。最后一条语句返回错误 DbExpressionBinding requires an input expression with a collec
我正在尝试声明类型为 AWSTaskCompletionSource 的变量,但我有 ` Generic parameter 'ResultType' could not be inferred 请看
我正在尝试弄清楚如何使用 struts2 XSL ResultType。除了 official documentation 之外,我只是不知道它应该如何工作。 ,我在网上找到了两篇试图解释它的文章(对
考虑创建使用 NSDictionary 作为 resultType 初始化的 NSFetchRequest: let fetchRequest = NSFetchRequest(entityName:
我的 linq 查询有一个大问题 var t = from tl in _GxEntities.T_L join td
根据一些有限的测试,我发现如果我 执行结果类型 = NSDictionaryResultType 的 Fetch 请求 对返回值进行一些操作 存储执行 Fetch 请求的 MOC 步骤 2 中的更改不
我试图在 MyBatis 中选择一个时间戳并将其作为 LocalDateTime(来自 joda-time)返回。 如果我尝试将结果作为 java.sql.Timestamp 返回,我的配置工作正常。
摘要 我有三个类(class): Account SpecialAccount (继承自 Account) Profile (0..1 与 SpecialAccount 的关系) 换句话说,一个 Sp
我在运行此查询时遇到异常(使用 LinqPad 进行调试): int[] serviceCodes= new int[] { 1610, 1611, 1612 }; byte[] payModes =
我正在尝试运行以下 linq 查询: var entries = from entry in _db.Entries select new CommentSummary() {
我收到此错误 DbExpressionBinding 需要一个带有集合 ResultType 的输入表达式。在使用 ASP.NET MVC 时仍然非常绿色,所以我不明白发生了什么以及为什么我会收到此错
当我将我的项目转换为 swift 3.0 时,我发现了这个错误 parameter 'ResultType' could not be inferred 我的代码是这样的: let fetchRequ
我正在使用 OData Nuget 包开发 Web API 原型(prototype)。 我在使 LINQ to EF 查询正常工作时遇到了一些问题。 Here are my data model.它
我有一个带有 TPT 继承的模型。 位置(抽象) 街道(派生自位置) GoogleStreetView(1 街道 -> 0..1 GoogleStreetView) 以上每个都有自己的表格。 在我添加
我正在开发 macOS 应用程序,并使用 CoreData 存储在数据库中。应用程序将支持 OS X 10.11 及更高版本。在 OS X 10.12 机器应用程序工作正常,但在 OS X 10.11
我是一名优秀的程序员,十分优秀!