[Solved] In c# where in clause works for integers?

If _ProjectContext.ProjectDetails has more then one phase item then it will throw exception. But if there is no matching element then it will return 0 var numbers = new[] {1 ,2, 3}; numbers.Where(x => x == 6).SingleOrDefault(); // returns 0 because default(int) == 0 1 solved In c# where in clause works for integers?

[Solved] Razor Page .NET Core 2.2 If + ElseIf statement doesn’t work in Lambda expression [duplicate]

I replaced this: .OrderBy(p => { if (p.Office == “President”) return 0; else if (p.Office == “Vice-President”) return 1; else if (p.Office == “Secretary-Treasurer”) return 2; }).ToListAsync(); with this: .OrderBy(p => p.Office == “President” ? 0 : p.Office == “Vice-President” ? 1 : p.Office == “Secretary-Treasurer” ? 2 : 3).ToListAsync(); I’m hoping it is useful … Read more