我想从动态linq查询创建where子句 [英] I want to create where clause from dynamic linq query
本文介绍了我想从动态linq查询创建where子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在下面的where子句的功能
I got below Functions for where clause
public static IQueryable<T> Where<T>(this IQueryable<T> source, string predicate, params object[] values)
{
return (IQueryable<T>)Where((IQueryable)source, predicate, values);
}
public static IQueryable Where(this IQueryable source, string predicate, params object[] values) {
if (source == null) throw new ArgumentNullException("source");
if (predicate == null) throw new ArgumentNullException("predicate");
LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, typeof(bool), predicate, values);
return source.Provider.CreateQuery(
Expression.Call(
typeof(Queryable), "Where",
new Type[] { source.ElementType },
source.Expression, Expression.Quote(lambda)));
}
但是如何从特定类型调用此函数...
But how to call this functions from specific type ...
public static IQueryable<mytable> Where<mytable>(this IQueryable<mytable> source, string predicate, params object[] values)
请任何人帮我..
please any one help me..
推荐答案
^ ]
LINQ中的动态where子句-具有可用的列名在运行时 [具有动态where子句的linq查询 [此处 [
Dynamic query with Linq[^]
Dynamic where clause in LINQ - with column names available at runtime[^]
linq query with dynamic where clause[^]
Many more similar results here[^]
这篇关于我想从动态linq查询创建where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文