Example
Exception:
-----------------------------System Exception Content-------------------------------
System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Max(IEnumerable`1 source)
at System.Linq.Enumerable.Max[TSource](IEnumerable`1 source, Func`2 selector)
Code Snippet which cause this issue:
int compSteps=0; if (appCompletedSteps.Count > 0) { compSteps = appCompletedSteps.Where(x => x.AppNumber == application.AppNumber).Max(y => y.StepID); }
Code Fix:
int compSteps=0; if (appCompletedSteps.Count > 0 && appCompletedSteps.Where(x => x.AppNumber == app.AppNumber).Any()) { compSteps = appCompletedSteps.Where(x => x.AppNumber == app.AppNumber).Max(y => y.StepID); }
No comments:
Post a Comment