如何使用简单的 Odata 过滤器比较 List 中的值?
how do I compare values from List using simple Odata filter?
如何编写将 Mylist-values 与 MyKeyTable-values 进行比较的过滤器?
我尝试了如下操作:
List<string> Mylist = new List<string>();
Mylist.Add("Welcome");
Mylist.Add("Hello");
var output = await client.For<MyKeyTable>()
//this is wrong I knew I need to correct this
.Filter(Mylist.Contains(x=>x.Key))
.FindEntriesAsync();
所以 output
将包含键值匹配的所有值,如 welcome
和 hello
提前致谢。
完成我用自定义表达式试过了
ParameterExpression pe = Expression.Parameter(typeof(MyTableClass), "entity");
Expression expression = null;
Expression predicateBody = null;
Expression leftExpression = Expression.Property(pe, "Key");
Expression rightExpression = Expression.Constant("Welcome");
expression = Expression.Equal(leftExpression, rightExpression);
predicateBody = predicateBody == null
? expression
: Expression.OrElse(predicateBody, expression);
如何编写将 Mylist-values 与 MyKeyTable-values 进行比较的过滤器?
我尝试了如下操作:
List<string> Mylist = new List<string>();
Mylist.Add("Welcome");
Mylist.Add("Hello");
var output = await client.For<MyKeyTable>()
//this is wrong I knew I need to correct this
.Filter(Mylist.Contains(x=>x.Key))
.FindEntriesAsync();
所以 output
将包含键值匹配的所有值,如 welcome
和 hello
提前致谢。
完成我用自定义表达式试过了
ParameterExpression pe = Expression.Parameter(typeof(MyTableClass), "entity");
Expression expression = null;
Expression predicateBody = null;
Expression leftExpression = Expression.Property(pe, "Key");
Expression rightExpression = Expression.Constant("Welcome");
expression = Expression.Equal(leftExpression, rightExpression);
predicateBody = predicateBody == null
? expression
: Expression.OrElse(predicateBody, expression);