小编jzw*_*man的帖子

替换表达式树中的参数值

搜索了很长一段时间后,我仍然没有找到我想要的答案。我找到了有关从树中添加和删除参数的答案,但没有找到有关替换特定参数的任何内容。

我的第一个方法按我希望的方式工作,我需要将partitionKey 值替换为Uri 转义值,然后返回未转义的结果。

public override IList<T> GetRowEntityList(string partitionKey)
{
    IList<T> rowEntities =  base.GetRowEntityList(Uri.EscapeDataString(partitionKey));
    return rowEntities.Select(UnEscapeRowEntity).ToList();
}
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是重写此方法以使其表现相同。我已经知道类型T具有属性PartitionKeyRowKey但也可以具有任何其他数量的属性。

对于示例谓词:

x => x.RowKey == "foo/bar" && x.SomeValue == "test" 
Run Code Online (Sandbox Code Playgroud)

我希望它成为

x => x.RowKey == Uri.EscapeDataString("foo/bar") && x.SomeValue == "test"  
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?

T我的基类使用此谓词对包含使用Where(predicate)调用的类型的实体的表进行表查找

public override IList<T> GetRowEntityList(System.Linq.Expressions.Expression<Func<T, bool>> predicate)
{
    //modify predicate value here

    return base.GetRowEntityList(predicate);
}
Run Code Online (Sandbox Code Playgroud)

c# linq expression

5
推荐指数
1
解决办法
1777
查看次数

怎么粉碎堆栈?

我有一个堆栈粉碎的小任务.那么什么是最简单的粉碎堆栈的方法?我只想要一个简单的说明性方法.

stack

2
推荐指数
1
解决办法
434
查看次数

标签 统计

c# ×1

expression ×1

linq ×1

stack ×1