示例#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();
     }
 }
示例#2
0
 private void ListProducts()
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         dgwProduct.DataSource = context.Products.ToList();
     }
 }
示例#3
0
 private void ListProductsByCategoryId(int categoryId)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         dgwProduct.DataSource = context.Products.Where(p => p.CategoryId == categoryId).ToList();
     }
 }
示例#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());
     }
 }
示例#7
0
 private void ListCategories()
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         cmbCategory.DataSource    = context.Categories.ToList();
         cmbCategory.DisplayMember = "CategoryName";
         cmbCategory.ValueMember   = "CategoryId";
     }
 }
示例#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);
        }