日期:2014-05-20 浏览次数:21181 次
[Query]
public IQueryable<ProMainenance> getProMainenancesBySearch(string queryField, string queryValue)
{
//s.[queryFiled]
ParameterExpression param = Expression.Parameter(typeof(ProMainenance), "s");
Expression selector = Expression.Property(param, typeof(ProMainenance).GetProperty(queryField));
Expression constant = Expression.Constant(queryValue);
Expression filter = Expression.Call(typeof(VehicleService).GetMethod("like", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public), selector, constant);
Expression<Func<ProMainenance, bool>> pred = Expression.Lambda<Func<ProMainenance, bool>>(filter, param);
return this.ObjectContext.ProMainenances.Where(pred);
}
static bool like(string a, string b)
{
return a.Contains(b);
}