Category category = categories.Where(x => x.CategoryId == whatever).Single();
...may be rewritten as...
Category category = categories.Single(x => x.CategoryId == whatever);
This is also legit code:
Category category = categories.FirstOrDefault(x => x.CategoryId == whatever);
No comments:
Post a Comment