//第一种方法
            DataClasses3DataContext con = new DataClasses3DataContext();
             
            var qu = from c in con.FeeMain select c;
             
            if (textBox1.Text != "")
                qu = qu.Where(c => c.wtdw == textBox1.Text);
            if (textBox2.Text != "")
                qu = qu.Where(c => c.vessel == textBox2.Text);
 
            dataGridView1.DataSource = qu;
//第二种方法
            DataClasses3DataContext con = new DataClasses3DataContext();
            var searchPredicate1 = PredicateExtensions.True<FeeMain>();
            if (textBox1.Text != "")
                searchPredicate1 = searchPredicate1.And(c => c.wtdw == textBox1.Text);
            if (textBox2.Text != "")
                searchPredicate1 = searchPredicate1.And(c => c.vessel == textBox2.Text);
 
            var a = from c in con.FeeMain.Where(searchPredicate1) select c;
            dataGridView1.DataSource = a;

 

相关文章:

  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2021-09-17
  • 2022-01-29
  • 2022-02-22
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-11-10
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案