예제 #1
0
파일: Program.cs 프로젝트: thedoomx/CSharp
        private static Book AddBook(string title, string description, DateTime datePublished, int pages, string isbn, int bookCopies)
        {
            using (BookDBDataContext context = new BookDBDataContext())
            {
                Book newBook = new Book()
                {
                    Title = title,
                    BookResume = description,
                    DatePublished = datePublished,
                    Pages = pages,
                    ISBN = isbn
                };

                context.Books.InsertOnSubmit(newBook);

                while (bookCopies > 0)
                {
                    var bookCopy = new BookCopy()
                    {
                        Book = newBook
                    };
                    context.BookCopies.InsertOnSubmit(bookCopy);
                    bookCopies--;
                }

                //var existing = context.Authors.FirstOrDefault(a => a.FirstName.Contains("G"));

                //if (existing != null)
                //{
                //    var bookAuthor = new BookAuthor()
                //    {
                //        BookID = newBook.ID,
                //        AuthorID = existing.ID
                //    };
                //}

                //var bookGenre = new BookGenre()
                //{
                //    BookID = newBook.ID
                //};

                context.SubmitChanges();
                return newBook;
            }
        }
예제 #2
0
 partial void DeleteBookCopy(BookCopy instance);
예제 #3
0
 partial void UpdateBookCopy(BookCopy instance);
예제 #4
0
 partial void InsertBookCopy(BookCopy instance);
예제 #5
0
		private void detach_BookCopies(BookCopy entity)
		{
			this.SendPropertyChanging();
			entity.Book = null;
		}
예제 #6
0
		private void attach_BookCopies(BookCopy entity)
		{
			this.SendPropertyChanging();
			entity.Book = this;
		}