Here I'm selecting descriptions from all FactoryOption with an Header of "TRANSMISSION"
tOptions = _vDetails.fOptions
.Where(x => (x.header != null && x.header.Value.ToUpper() == "TRANSMISSION"))
.Select(x => x.description)
.SelectMany(x => x);
If the header is null I would like to search for the header in ambiguous options which matches to "TRANSMISSION"
Something like the following :
foreach (var fOptions in _vDetails.fOptions)
{
if (fOptions.header != null && fOptions.header.Value.ToUpper() == "TRANSMISSION")
{
tOptions = fOptions.description;
}
else if (fOptions.ambiguousOption != null)
{
foreach (var ambiguousOption in fOptions.ambiguousOption)
{
if (ambiguousOption.header != null && ambiguousOption.header.Value.ToUpper() == "TRANSMISSION")
{
newseq = tOptions.Concat(ambiguousOption.description);
}
}
}
}
I am trying to change existing LINQ lambda expression for iterating through fOptions.ambiguousOption
could someone please suggest.
If I'm understanding correctly I think you just want to do something like this:
I added a static method to check the header:
This will return
IEnumerable<string>
. If you want aIEnumerable<IEnumerable<string>>
change theSelectMany
toSelect
.EDIT:
To get all Transmission description values from
ambigousOptions
you need to change the last line so it looks like this: