我正在尝试让以下 LINQ 查询对数据库(3.5 SP1)起作用:
var labelIds = new List<int> { 1, 2 };
var customersAggregatedTransactionsByType =
(from transactions in context.TransactionSet
from customers in context.CustomerSet
.Where(LinqTools.BuildContainsExpression<Billing.Customer, int>(u => u.LabelId, labelIds))
from accounts in context.AccountSet
where customers == accounts.Customer
&& accounts.Id == transactions.Account.Id
&& transactions.DateTime >= fromDate && transactions.DateTime < toDate
group transactions.Amount
by new
{
UserAccountId = transactions.Account.Id,
TransactionTypeId = transactions.TransactionTypeId,
BaseAssetId = accounts.BaseAssetId
} into customerTransactions
select customerTransactions).ToList();
添加Where(LinqTools.BuildContainsExpression<Billing.Customer, int>(u => u.LabelId, labelIds))
后,我得到以下异常:
System.InvalidOperationException:内部 .NET Framework 数据提供程序错误 1025。
如果我删除Where(LinqTools.BuildContainsExpression<Billing.Customer, int>(u => u.LabelId, labelIds))
一切都很好。
任何帮助将不胜感激。
谢谢,尼尔。