Esempio n. 1
0
 private void ListProductsByProductName(string key)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         dgwProduct.DataSource = context.Products.Where(p => p.ProductName.ToLower().Contains(key.ToLower())).ToList();
     }
 }
Esempio n. 2
0
 private void ListProducts()
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         dgwProduct.DataSource = context.Products.ToList();
     }
 }
Esempio n. 3
0
 private void ListProductsByCategoryId(int categoryId)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         dgwProduct.DataSource = context.Products.Where(p => p.CategoryId == categoryId).ToList();
     }
 }
Esempio n. 4
0
 private void ListProducts()
 {
     using (NorthWindContext context = new NorthWindContext()) // idisposible format - garbage collector beklemeden memory den bitirmek.
     {
         dgwProduct.DataSource = context.Products.ToList();
     }
 }
 public void ListProductsByCategoryName(int categoryId)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         dataGridView1.DataSource = context.Products.Where(p => p.CategoryId == categoryId).ToList();
     }
 }
 public List <Product> ListByProductName(string key)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         return(context.Products.Where(p => p.ProductName.Contains(key)).ToList());
     }
 }
Esempio n. 7
0
 private void ListCategories()
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         cmbCategory.DataSource    = context.Categories.ToList();
         cmbCategory.DisplayMember = "CategoryName";
         cmbCategory.ValueMember   = "CategoryId";
     }
 }
Esempio n. 8
0
 private void ListCategories()
 {
     using (NorthWindContext context = new NorthWindContext()) // idisposible format - garbage collector beklemeden memory den bitirmek.
     {
         cbxCategory.DataSource    = context.Categories.ToList();
         cbxCategory.DisplayMember = "CategoryName";
         cbxCategory.ValueMember   = "CategoryId";
     }
 }
        private void txtCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            NorthWindContext context = new NorthWindContext();

            ListProductsByCategoryName(txtCategory.SelectedIndex);
        }