如何将此LINQ查询转换为lambda查询?
public List<Tuple<Klasa2,Klasa2>>CompareLists(List<Klasa2>list1,List<Klasa2>list2)
{
var pary=
from l1 in list1
from l2 in list2
where l1.tytul.Length<l2.tytul.Length
select new Tuple<Klasa2,Klasa2>(l1,l2);
return pary.ToList();
}
答案 0 :(得分:0)
这是你在找什么?
public List<Tuple<Klasa2, Klasa2>> CompareLists(List<Klasa2> list1, List<Klasa2> list2)
{
var pary =
list1.SelectMany(l1 => list2, (l1, l2) => new {l1, l2})
.Where(@t => @t.l1.tytul.Length < @t.l2.tytul.Length)
.Select(@t => new Tuple<Klasa2, Klasa2>(@t.l1, @t.l2));
return pary.ToList();
}