private static Author CreateOrLoadAuthor(BookstoreEntities context, string authorName) { var user = context.Authors.FirstOrDefault(x => x.Name == authorName); if (user != null) { return user; } var newAuthor = new Author { Name = authorName }; context.Authors.Add(newAuthor); context.SaveChanges(); return newAuthor; }
public Review() { this.author = new Author(); }