Tip: Use the LINQ methods that take a predicate

3 Feb 2010 09:33

Instead of this:

var author = (from a in dataContext.Authors where a.Id == authorId select a).Single();

…use this:

var author = dataContext.Authors.Single(a => a.Id == authorId);

Also consider whether you wanted SingleOrDefault.