linq自定义条件Lambda过滤方法
Public Func<NoramalClass,bool>simpleComare<NormalClass>(string property,object value)
{
var type=typeof(NoramalClass);
var pe=Expression.Parameter(type,"p");
var propertyReference=Expression.Propery(pe,property);
var constantReferecnce=Expression.Constant(value);
return Expression.Lambda<Func<NormalClass,boo>>(Expression.Equal(propertyReferecnce,constantReferecnce),pe).Compile();
}
//查询某一列
Public Func<NoramalClass,string>simpleComare<NormalClass>(string property)
{
var type=typeof(NoramalClass);
var pe=Expression.Parameter(type,"p");
var propertyReference=Expression.Propery(pe,property);
return Expression.Lambda<Func<NormalClass,string>>(propertyReferecnce,pe).Compile();
}