解决方案 »
- SQL的一个查询语句请教
- 好东西,看看有你需要的没有?
- 50分求打印DataTable 里的数据方案呀。有急用呀。有的给带代看看呀。大家帮帮我好不好???
- @@@@@@@@@@@@@@@@@@@@一个简单的问题
- 如何应用MDI子窗体的句柄激活窗体?
- 怎样使Form3窗体在最前面显示?
- 关于多线程中的timer事件问题!!!(十万火急,在线等候)
- 怎么把delphi写的这几个方法,改成C#语言的?
- 中文字符全部变成???????????????????????????????????
- DotNetty 只能运行在控制台应用 怎么办
- 强类型和弱类型dataset 在更新数据库方面的区别是什么?(我不会用强类型更新)
- C#反射可以获取静态方法么,如果可以该怎么弄?
if (this.txtKeyWord.Text != "")
{
rowFilter += "DropType.SelectedValue like '%" + txtKeyWord.Text.Trim() + "%' ;
}现在我想用Lambda表达式动态过滤
怎么解决?
C# code
//DataView下过渡条件
if (this.txtKeyWord.Text != "")
{
rowFilter += DropType.SelectedValue+"like '%" + txtKeyWord.Text.Trim() + "%' ;
}
现在我想用Lambda表达式动态过滤
怎么解决
http://www.cnblogs.com/Magicworks/archive/2011/04/10/2011725.html
http://blog.csdn.net/q107770540/archive/2011/01/13/6133484.aspx
PropertyInfo prop = typeof(MO_v_Kid_Promotion).GetProperty(this.DropType.SelectedValue);
// Cache["KidPromotion"] = List;
if (this.txtKeyWord.Text != "")
{
List = List.Where(Items => { return IsKeyWord(prop.GetValue(Items, null), txtKeyWord.Text); }).ToList();
}
public bool IsKeyWord(object a, string b)
{
return (a != null) ? a.ToString().Contains(b) : false;
}
using System.Linq.Dynamic;var list = new List<TestObj>
{
new TestObj{A="1",B=1},
new TestObj{A="2",B=1},
new TestObj{A="3",B=1},
new TestObj{A="4",B=1},
};
var result = list.AsQueryable().Select("A");
foreach (var val in result)
Console.WriteLine(val);不过这个result是内部的EnumableQuery<T>对象,你只能拿来foreach取值。
string s = "name";
List<TestModel> lst = new List<TestModel>();
lst.Add(new TestModel() { name = "张三", id = "001", sex = "男" });
lst.Add(new TestModel() { name = "李四", id = "002", sex = "女" });
lst.Add(new TestModel() { name = "王五", id = "003", sex = "男" });
lst.Add(new TestModel() { name = "赵六", id = "004", sex = "男" });
PropertyInfo pi = typeof(TestModel).GetProperty(s);
List<TestModel> lstNew = lst.Where(p => pi.GetValue(p,null).ToString() == "张三").ToList();
跑来CSDN问问题