这是我现有的代码,只读取我插入的数据的变量。但我想搜索一个总的查询,例如 select * from (Table);
private void searchtxt_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
if(string.IsNullOrEmpty(searchtxt.Text))
{
dataGridView.DataSource = artistBindingSource;
}
else
{
var query = from o in artistBindingSource.DataSource as List<artist>
where o.cnic == searchtxt.Text || o.first_name.Contains(searchtxt.Text) ||
o.last_name.Contains(searchtxt.Text) || o.phone.Equals(searchtxt.Text) ||
o.gender.Contains(searchtxt.Text) || o.date_of_birth.Equals(searchtxt.Text)
select o;
dataGridView.DataSource = query.ToList();
}
}
}