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();
        }

原文地址:http://www.cnblogs.com/wangshijie/archive/2009/05/09/1453340.html

相关文章:

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