Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,710 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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;
}
If you do not need the qryPanelIndex list for other purposes, then try something like this:
bool iscState = CurrentProduct.MainList[0].ListSingleBoards.Any( b => b.ListPosition.Any( p => p.State.HasFlag( StatePosition.ProcessWrong ) );