예제 #1
0
 public List <string> GetBooksNames()
 {
     using (SampleDbEntities entities = new SampleDbEntities())
     {
         return(entities.Books.Select(book => book.BookName).ToList());
     }
 }
 public List<string> GetBooksNames()
 {
     using (SampleDbEntities entities = new SampleDbEntities())
     {
         return entities.Books.Select(book => book.BookName).ToList();
     }
 }
예제 #3
0
 public List <Book> GetBooksList()
 {
     using (SampleDbEntities entities = new SampleDbEntities())
     {
         return(entities.Books.ToList());
     }
 }
 public List<Book> GetBooksList()
 {
     using (SampleDbEntities entities = new SampleDbEntities())
     {
         return entities.Books.ToList();
     }
 }
 public void AddBook(string name)
 {
     using (SampleDbEntities entities = new SampleDbEntities())
     {
         Book book = new Book { BookName = name };
         entities.Books.AddObject(book);
         entities.SaveChanges();
     }
 }
예제 #6
0
 public void AddBook(string name)
 {
     using (SampleDbEntities entities = new SampleDbEntities())
     {
         Book book = new Book {
             BookName = name
         };
         entities.Books.AddObject(book);
         entities.SaveChanges();
     }
 }
예제 #7
0
        public Book GetBookById(string id)
        {
            try
            {
                int bookId = Convert.ToInt32(id);

                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    return(entities.Books.SingleOrDefault(book => book.ID == bookId));
                }
            }
            catch
            {
                throw new FaultException("Something went wrong");
            }
        }
        public Book GetBookById(string id)
        {
            try
            {
                int bookId = Convert.ToInt32(id);

                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    return entities.Books.SingleOrDefault(book => book.ID == bookId);
                }
            }
            catch
            {
                throw new FaultException("Something went wrong");
            }
        }
예제 #9
0
        public void DeleteBook(string id)
        {
            try
            {
                int bookId = Convert.ToInt32(id);

                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    Book book = entities.Books.SingleOrDefault(b => b.ID == bookId);
                    entities.Books.DeleteObject(book);
                    entities.SaveChanges();
                }
            }
            catch
            {
                throw new FaultException("Something went wrong");
            }
        }
예제 #10
0
        public void UpdateBook(string id, string name)
        {
            try
            {
                int bookId = Convert.ToInt32(id);

                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    Book book = entities.Books.SingleOrDefault(b => b.ID == bookId);
                    book.BookName = name;
                    entities.SaveChanges();
                }
            }
            catch
            {
                throw new FaultException("Something went wrong");
            }
        }
        public void UpdateBook(string id, string name)
        {
            try
            {
                int bookId = Convert.ToInt32(id);

                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    Book book = entities.Books.SingleOrDefault(b => b.ID == bookId);
                    book.BookName = name;
                    entities.SaveChanges();
                }
            }
            catch
            {
                throw new FaultException("Something went wrong");
            }
        }
        public void DeleteBook(string id)
        {
            try
            {
                int bookId = Convert.ToInt32(id);

                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    Book book = entities.Books.SingleOrDefault(b => b.ID == bookId);
                    entities.Books.DeleteObject(book);
                    entities.SaveChanges();
                }
            }
            catch
            {
                throw new FaultException("Something went wrong");
            }
        }