private void ViewBinding()
        {    
            Expression<Func<TestTable, bool>> expr = n => GetCondition(n);
            var xQuery = DCDataContext.TestTables.Where<TestTable>(expr.Compile());
            this.dataGridView1.DataSource = xQuery.ToList<TestTable>();
        }
        private bool GetCondition(TestTable tb)
        {
            bool boolResult = true;
            if (txtUserNumber.Text.Trim() != string.Empty)
            {
                boolResult &= tb.UserNumber == int.Parse(txtUserNumber.Text.Trim());
            }
            if (txtName.Text.Trim() != string.Empty)
            {
                boolResult &= tb.Name == txtName.Text.Trim();
            }
            if (txtClassName.Text.Trim() != string.Empty)
            {
                boolResult &= tb.ClassName == txtClassName.Text.Trim();
            }
            return boolResult;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ViewBinding();
        }

相关文章:

  • 2021-09-25
  • 2021-06-04
  • 2021-07-31
  • 2022-12-23
  • 2021-08-26
  • 2021-07-18
  • 2022-12-23
  • 2021-06-02
猜你喜欢
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案