C# 从Linq语句获取字典输出
这是我的实体收藏C# 从Linq语句获取字典输出,c#,asp.net,linq,C#,Asp.net,Linq,这是我的实体收藏 Dictionary<string, List<Dictionary<string, string>>> EntityCollection = new Dictionary<string, List<Dictionary<string, string>>>(); 现在我只需要实体.value。 所以我创建了一个变量: List<Dictionary<string, string>>
Dictionary<string, List<Dictionary<string, string>>> EntityCollection = new Dictionary<string, List<Dictionary<string, string>>>();
现在我只需要实体.value
。
所以我创建了一个变量:
List<Dictionary<string, string>> entityDetails = new List<Dictionary<string, string>>();
List entityDetails=new List();
如何将筛选的转换为实体详细信息
我尝试了筛选。ToList
,但没有成功。您可以直接从字典
获取,而不是像您一样使用LINQ:
List<Dictionary<string, string>> entityDetails = EntityCollection[entityId];
List entityDetails=EntityCollection[entityId];
或者,如果字典没有键,您希望避免第一种方法的异常
List<Dictionary<string, string>> entityDetails;
if (EntityCollection.TryGetValue(entityId, out entityDetails))
{
}
列出实体详细信息;
if(EntityCollection.TryGetValue(entityId,out entityDetails))
{
}
List<Dictionary<string, string>> entityDetails;
if (EntityCollection.TryGetValue(entityId, out entityDetails))
{
}