private void LoadCategories() { using (dbModelContainer db = new dbModelContainer()) { var categories = db.Category.ToList(); CategoryList.DataSource = categories; CategoryList.DataBind(); } }
private void LoadBooks() { using (dbModelContainer db = new dbModelContainer()) { var books = db.Book.ToList(); BookList.DataSource = books; BookList.DataBind(); } }
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(); } }
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(); } }
public static void Init() { ModelContainer = new dbModelContainer(); }