我有DataGridView
绑定到实体上下文,如下所示
var leader = from l in myEntity.Leaders
select new { l.TeamName, ,l.Name ,l.Family, l.InsuranceNumber, l.Mobile };
DataGridView1.DataSource = leader;
现在,我想过滤DataGridView行,例如
where Name like 'A%'
我该怎么做?
答案 0 :(得分:0)
使用LINQ过滤您的收藏:
var filteredLeaders = leader.Where(o=>o.Name.StartsWith("A"));
然后重新绑定你的网格:
DataGridView1.DataSource = filteredLeaders;
答案 1 :(得分:0)
Linq to SQL很有用。
有一种形式
var x = from T in db.Table where [usual where stuff goes here];