I’m trying to switch this linq code to a lambda expression:
foreach (var id in orderLinesToSplit)
{
int result =
(from ol in orderLines
from splittedOl in orderLines
where ol.Key == id
&& ol.Value == splittedOl.Value
&& ol.Key != splittedOl.Key
select splittedOl.Key).FirstOrDefault();
}
The goal is to get a Dictionary<int, int> of pairs id (from oderLinesToSplit) and result (the result from the linq query). Can it be done with just one lambda expression?
Thanks
Or if you really want it in one expression. Then something like this:
Where db is the linq data context