示例#1
0
 private void LoadCategories()
 {
     using (dbModelContainer db = new dbModelContainer())
     {
         var categories = db.Category.ToList();
         CategoryList.DataSource = categories;
         CategoryList.DataBind();
     }
 }
示例#2
0
 private void LoadBooks()
 {
     using (dbModelContainer db = new dbModelContainer())
     {
         var books = db.Book.ToList();
         BookList.DataSource = books;
         BookList.DataBind();
     }
 }
示例#3
0
 private void LoadBooks(string keyword)
 {
     using (dbModelContainer db = new dbModelContainer())
     {
         var books = (from i in db.Book
                      where i.BookName.Contains(keyword) || i.Description.Contains(keyword)
                      select i).ToList();
         BookList.DataSource = books;
         BookList.DataBind();
     }
 }
示例#4
0
        private void LoadBooks(int id)
        {
            using (dbModelContainer db = new dbModelContainer())
            {
                var books = from c in db.Category.Where(c => c.Category_Book.Any())
                            from cb in db.Category_Book.Where(cb => cb.CategoryId.Equals(c.Id))
                            from b in db.Book.Where(b => b.Id.Equals(cb.BookId))
                            where c.Id == id
                            select new { b.BookName, b.Price, b.Image };

                BookList.DataSource = books.ToList();
                BookList.DataBind();
            }
        }
示例#5
0
 public static void Init()
 {
     ModelContainer = new dbModelContainer();
 }