Hello,
The below code works very well.
The question is, can I solve this in one query?
If so, how would I implement it?
I want to know if a position has a bad status. If so, the product is bad. Return value is bool.
Thanks for tips in advance!
var qryPanelIndex = CurrentProduct.MainList[0].ListSingleBoards.GroupBy(info => info.PanelIndex)
.Select(group => new
{
PanelIndex = group.Key,
CountOccurrences = group.Count(),
PanelListPos = group.ToArray() //.ToList().Where(pos => pos.ListPosition.Any(cState => cState.State.HasFlag(StatePosition.ProcessWrong) == true)).FirstOrDefault()
})
.OrderBy(x => x.PanelIndex).ToList();
bool iscState = false;
foreach(var item in qryPanelIndex)
{
foreach( var subitem in item.PanelListPos)
{
iscState = subitem.ListPosition.Any(st => st.State.HasFlag(StatePosition.ProcessWrong));
if (iscState)
break;
}
if (iscState)
break;
}