var details= from row in databaseTablewhere row.id equals queryIdselect new {Dict = row.ToDictionary(x = x.Name, x = x.Value),};执行此LINQ to SQL时,我得到错误;System.NotSupportedException: Thequery ...

var details= from row in databaseTable
where row.id equals queryId
select new
{
Dict = row.ToDictionary(x => x.Name, x => x.Value),
};
执行此LINQ to SQL时,我得到错误;
System.NotSupportedException: The
query operator ‘ToDictionary’ is not
supported.
我需要做的是先将行拉入内存,但我不确定如何.我尝试在各个地方调用ToList,但没有运气.
解决方法:
var fixTotaliserDetails = (from row in databaseTable
where row.id == queryId
select new
{
row.Name,
row.Value,
})
.ToDictionary(x=>x.Name, x=>x.Value);
这会奏效.我认为你可能过度简化了你的答案,因为在linq-to-sql中,表中的项目没有实现IEnumerable< T>
织梦狗教程
本文标题为:c# – LINQ to SQL – 不支持ToDictionary – 如何将结果提取到内存中?


基础教程推荐
猜你喜欢
- C# RSA分段加解密实现方法详解 2022-11-09
- 解答“60k”大佬的19道C#面试题(下) 2023-02-25
- Unity实现相机截图功能 2023-02-16
- 浅谈C# 字段和属性 2023-03-03
- c# HashSet的扩容机制需要注意的 2023-02-25
- C#基于自定义事件EventArgs实现发布订阅模式 2023-06-04
- C#中ref关键字的用法 2023-06-27
- 事务在c#中的使用 2023-06-04
- C#如何添加PPT背景 2022-12-30
- c# – 从中获取数据然后返回Windows剪贴板 2023-09-20