使用 Radgrid 过滤器表达式查询集合给出异常 'Expression Expected'
Using Radgrid filter expression to query collection gives exception 'Expression Expected'
我正在尝试使用我的 radgrid 中的过滤器表达式查询一个集合。在 RadGrid 上我有 属性 of EnableLinqExpressions = "false"
但是我在使用代码时遇到异常 Expression Expected
:
results = results.Where(filterExpression);
目前过滤表达式的格式为
"(([SCRIPT_AGENT] = 'Jack Davies'))"
我该如何解决这个问题?
当我输入以下内容时,它起作用了:
results = results.Where("SCRIPT_AGENT == @0", "Jack Davies")
是否可以使用我当前的过滤器表达式,或者是否可以通过某种方式将其转换为可用格式?
我决定使用不同的方法并在应用过滤器时使用 rad 网格本身中的当前数据,而不是使用 rad 网格的过滤器表达式:
// If there is a filter applied then enter the loop if there isn't then the filter expression will be empty
if (!String.IsNullOrEmpty(filterExpression))
{
// Create a new list of strings to hold the sequence ids
List<string> sequenceIds = new List<string>();
// For each row in the radgrid...
foreach (GridDataItem row in rgCallRecordings.Items) // loops through each rows in RadGrid
{
// ...Add the sequence id to the list
sequenceIds.Add(row.GetDataKeyValue("SEQUENCE_ID").ToString());
}
// Only return results whose sequence ids are in the list
results = results.Where(a => sequenceIds.Contains(a.SEQUENCE_ID));
}
这消除了错误并产生了与使用过滤器表达式相同的结果。
我正在尝试使用我的 radgrid 中的过滤器表达式查询一个集合。在 RadGrid 上我有 属性 of EnableLinqExpressions = "false"
但是我在使用代码时遇到异常 Expression Expected
:
results = results.Where(filterExpression);
目前过滤表达式的格式为
"(([SCRIPT_AGENT] = 'Jack Davies'))"
我该如何解决这个问题?
当我输入以下内容时,它起作用了:
results = results.Where("SCRIPT_AGENT == @0", "Jack Davies")
是否可以使用我当前的过滤器表达式,或者是否可以通过某种方式将其转换为可用格式?
我决定使用不同的方法并在应用过滤器时使用 rad 网格本身中的当前数据,而不是使用 rad 网格的过滤器表达式:
// If there is a filter applied then enter the loop if there isn't then the filter expression will be empty
if (!String.IsNullOrEmpty(filterExpression))
{
// Create a new list of strings to hold the sequence ids
List<string> sequenceIds = new List<string>();
// For each row in the radgrid...
foreach (GridDataItem row in rgCallRecordings.Items) // loops through each rows in RadGrid
{
// ...Add the sequence id to the list
sequenceIds.Add(row.GetDataKeyValue("SEQUENCE_ID").ToString());
}
// Only return results whose sequence ids are in the list
results = results.Where(a => sequenceIds.Contains(a.SEQUENCE_ID));
}
这消除了错误并产生了与使用过滤器表达式相同的结果。