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 ...
![](https://oss.womengda.net/imgfile/2310/1ER2IRZ510-291b.jpg)
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 – 如何将结果提取到内存中?
![](/xwassets/images/pre.png)
![](/xwassets/images/next.png)
猜你喜欢
- C#入门之定义类成员与接口实现 2023-06-05
- Unity实战之FlyPin(见缝插针)小游戏的实现 2023-05-12
- Asp.Net(C#)使用oleDbConnection 连接Excel的方法 2023-01-06
- Unity5.6大规模地形资源创建方法 2023-01-16
- C# VB.NET 将Html转为Excel 2023-05-26
- Unity实现俄罗斯方块(一) 2023-03-03
- c# rsa加密解密详解 2023-03-03
- 另一个进程使用的文件c# 2023-09-19
- C# 连接 Oracle 的几种方式 2023-11-15
- c# this关键字用法代码详解 2023-02-08