过滤此Linq查询 [英] Filtering this Linq query
本文介绍了过滤此Linq查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要使用此查询:
var queryData = from va in xdoc.Descendants("language")
select new
{
StringID = va.Parent.Parent.Attribute("id").Value,
Language = va.Attribute("name").Value,
LanguageData = va.Element("value").Value,
};
var organizedData = from x in queryData
group x by x.StringID into xg
select new
{
StringID = xg.Key,
English = xg.SingleOrDefault(x => x.Language == "ENGLISH_US").LanguageData,
Custom = xg.SingleOrDefault(x => x.Language == languageBox.SelectedItem.ToString()).LanguageData,
};
mainView.DataSource = organizedData.ToList();
mainView.Refresh();
除了作为Custom
匿名类型检索的内容的附加条件外,其值必须等于"*"
.
except that as an additional condition for what is retrieved for the Custom
anonymous type, its value must be equal to "*"
.
为什么我不能弄清楚呢?我想我对匿名类型或=>
运算符的了解还不够.
Why can't I figure this out? I guess I don't know enough about anonymous types or the =>
operator.
推荐答案
这就是您想要的吗?
mainView.DataSource = organizedData.Where(x => x.Custom == "*").ToList();
这篇关于过滤此Linq查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文