Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 public Review()
 {
     this.author = new Author();
 }