예제 #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;
        }
예제 #2
0
 public Review()
 {
     this.author = new Author();
 }