Tôi đang cố gắng để có được những truy vấn LINQ sau đây để làm việc chống lại cơ sở dữ liệu (3.5 SP1):Entity Framework BuildContainsExpression Nguyên nhân nội .NET Framework cung cấp dữ liệu lỗi 1025
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();
Khi tôi thêm Where(LinqTools.BuildContainsExpression<Billing.Customer, int>(u => u.LabelId, labelIds))
tôi nhận được như sau ngoại lệ:
System.InvalidOperationException: Internal .NET Framework cung cấp dữ liệu lỗi 1025.
Nếu tôi loại bỏ Where(LinqTools.BuildContainsExpression<Billing.Customer, int>(u => u.LabelId, labelIds))
tất cả là tốt.
Mọi trợ giúp sẽ được đánh giá cao.
Cảm ơn, Nir.
Điều đó xảy ra! Cảm ơn rất nhiều! – nirpi
Ồ, bạn thiên tài! Tôi đã mở một khoản tiền thưởng cho [câu hỏi tương tự] (http://stackoverflow.com/q/11990158/7850) chỉ một giờ trước, và chỉ sau đó mới tìm được câu trả lời của bạn. Hãy đi và nhận cho mình một tiền thưởng ở đó. –
Nghe có vẻ hiển nhiên, nhưng bạn đúng, biểu thức phải được xây dựng bên ngoài chính truy vấn đó. –