Last post May 13, 2019 01:23 AM by wavemaster
May 09, 2019 08:49 PM|wavemaster|LINK
pack.Data.Values contains several dictionary objects.
It is passed into a method for further processing. In the method there is some linq code that returns a list of endPointIds:
dp.Select(d => d.EndpointId)
Stuff is done with that list of endPoints.
I need to add an extra condition to that linq code to only get those where the doProcess flag is set to true.
doProcess is a nullable bool
dp.Select(d => d.EndpointId && d.doProcess.HasValue)
and also tried
dp.Select(d => d.EndpointId && (d.doProcess ?? true))
Either results in the error message from the title.
How to correct this?
May 09, 2019 10:52 PM|DA924|LINK
If it really is a Boolean value
dp.Select.Where(d => d.doProcess) // it's implied that the Boolean value is = true
dp.Select.Where(d => d.doProcess == true)
I don't know what d.EndpointId is about in some selection criteria based on a Where clause.
May 10, 2019 01:18 AM|wavemaster|LINK
In simple form:
endPointId / doProcess
6 / false
8 / true
12 / true
16 / false
Currently I am getting a list of 6 8 12 16
What I need is 8 12
How can I achieve that?
The dp.Select(d => d.EndpointId) just takes the endPointId from each object.
May 10, 2019 07:48 AM|DA924|LINK
var results = (from a in dp.where(d => d.Value == true) select a.Key, a.Value).ToList();
foreach(var result in results)
var key = result.Key; var value = result.Value;
I don't know try it.
May 13, 2019 01:23 AM|wavemaster|LINK
Figured it out: problem was my lack of understanding the difference between SELECT and WHERE in Linq.
Very well explained here: https://stackoverflow.com/questions/1212746/linq-what-is-the-difference-between-select-and-where
I was trying to combine a SELECT and WHERE in the same Linq magic.
This came to light after I broke the functionality into two.