Spring.Caching.AspNetCache-基于ReturnValue的条件-Spring表达式语言中的条件

Spring.Caching.AspNetCache-基于ReturnValue的条件-Spring表达式语言中的条件,caching,spring.net,spring-aop,spring-el,Caching,Spring.net,Spring Aop,Spring El,我将缓存特性与ASP.NET缓存一起使用。我需要根据返回值创建条件 我简化了我的问题。我在返回简单POCO对象的方法上使用CacheResult方面 以下是定义: 公共类MyData { 公共字符串MyProperty{get;set;} } 公共类MyResponse { 公共int MyId{get;set;} 公共MyData[]结果{get;set;} } 只有当MyResponse.MyData.Lenght大于批处理限制时,我才需要为缓存-缓存结果创建条件 [CacheResult

我将缓存特性与ASP.NET缓存一起使用。我需要根据返回值创建条件

我简化了我的问题。我在返回简单POCO对象的方法上使用CacheResult方面

以下是定义:

公共类MyData
{
公共字符串MyProperty{get;set;}
}
公共类MyResponse
{
公共int MyId{get;set;}
公共MyData[]结果{get;set;}
}
只有当MyResponse.MyData.Lenght大于批处理限制时,我才需要为缓存-缓存结果创建条件

[CacheResult(“AspNetCache”),“'MyResponse.MyId='+#id”,
条件=“MyResponse.Result.Length>#batchLimit”)]
公共MyResponse GetResponse(int id,int batchLimit)
{
睡眠(5000);
返回新的MyResponse
{
MyId=1,
结果=
新MyData[]
{
新建MyData{MyProperty=“A”},新建MyData{MyProperty=“B”},
新的MyData{MyProperty=“C”},
}
};
}
我尝试过这种条件的定义:

Condition = "MyResponse.Result.Length > #batchLimit"
我得到了这个错误:

无法为指定的上下文解析“MyResponse”节点 [Sample.MyResponse]

所以我尝试了第二个版本:

Condition = "'MyResponse.Result.Length' > #batchLimit"
完成时出现错误:

Cannot compare instances of [System.String] and [System.Int32] because they cannot be coerced to the same type.
我用谷歌搜索它我可以使用关键字
ReturnValue
类似这样的东西:

Condition = "#ReturnValue != null"

但是我不知道如何访问
MyResponse.MyData.Length

条件表达式的计算上下文是返回值,所以只需执行以下操作:

Condition = "Result.Length > #batchLimit"
相当于

Condition = "#root.Result.Length > #batchLimit"