如何编写将Mylist值与MyKeyTable值进行比较的过滤器?
我尝试过以下内容:
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
提前致谢。
答案 0 :(得分:0)
完成后我尝试使用自定义表达式
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);