语法LINQ的IEnumerable&LT;字符串&GT; [英] syntax in LINQ IEnumerable<string>
本文介绍了语法LINQ的IEnumerable&LT;字符串&GT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的code,它的伟大工程:
I prepository代表=新的I prepository();
变种Q = rep.GetIp()
。凡(X =&GT; x.CITY == CITY)
.GroupBy(Y =&GT; o.Fam)
。选择(Z =&gt;新建IpDTO
{
IID = z.Key.Id,
IP = z.Select(X =&GT; x.IP).Distinct()
});
IP是的IEnumerable&LT;字符串&GT;
- 我需要添加到这个code调用一个函数
PAINTIP(IP)
以上。 - 我需要发送,这将是内部IP给一个函数
PAINTIP(IP)
元素中的每一个。 因此,我需要使用某种形式的foreach功能,但我无法弄清楚如何。
解决方案
rep.GetIp()
。凡(X =&GT; x.CITY == CITY)
.GroupBy(Y =&GT; o.Fam)
。选择(Z =&gt;新建IpDTO
{
IID = z.Key.Id,
IP = z.Select(X =&GT; x.IP).Distinct()
})
.SelectMany(项目=&GT; item.IP)
.ToList()
.ForEach(PAINTIP)
This is my code that works great:
IPRepository rep = new IPRepository();
var Q = rep.GetIp()
.Where(x => x.CITY == CITY)
.GroupBy(y => o.Fam)
.Select(z => new IpDTO
{
IId = z.Key.Id,
IP = z.Select(x => x.IP).Distinct()
});
IP is IEnumerable<string>
- I need to add to this code above a call to a function
PAINTIP(ip)
. - I need to send each one of the elements that will be inside IP to a function
PAINTIP(ip)
. therefore i need to use some kind of foreach function but i cannot figure out how.
解决方案
rep.GetIp()
.Where(x => x.CITY == CITY)
.GroupBy(y => o.Fam)
.Select(z => new IpDTO
{
IId = z.Key.Id,
IP = z.Select(x => x.IP).Distinct()
})
.SelectMany(item => item.IP)
.ToList()
.ForEach(PAINTIP)
这篇关于语法LINQ的IEnumerable&LT;字符串&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文