我有以下LINQ查询:
var allocations =
from ta in dc.TransactionAllocations
where ta.Allocated == false
group ta by new { ta.ReceiptReference, ta.Customer } into tag
select new
{
Customer = tag.Key.Customer,
ReceiptReference = tag.Key.ReceiptReference,
Invoices = tag.ToDictionary(a => new AllocationDictionaryKey()
{
ID = a.ID,
InvoiceReference = a.InvoiceReference
},
a => a.Amount)
}但是,当我尝试执行此操作时,ToDictionary调用失败,因为它不是受支持的LINQ- to -SQL运算符。解决这个问题的唯一方法是在查询结束时调用ToDictionary,但我只希望匿名类型的一个属性是字典!
有没有关于如何开始这样做的想法?
发布于 2011-10-06 16:19:03
看看如何使用AsEnumerable。这是为了获取特定平台不支持的舍入运算符。这意味着数据将在代码所在的位置而不是数据所在的位置进行处理。
Invoices = tag.AsEnumerable().ToDictionary(a => new AllocationDictionaryKey() { ID = a.ID, InvoiceReference = a.InvoiceReference }, a => a.Amount)发布于 2012-10-04 19:31:17
很老了,但现在开始了。我解决了我的问题
from ta in dc.TransactionAllocations.AsEnumerable()即直接使数据表成为可枚举的。
https://stackoverflow.com/questions/7671708
复制相似问题