Tip: Use the LINQ methods that take a predicate

roger's picture

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.