This question is locked. New answers and comments are not allowed.
Hi guys:)
When the grid is bound to a WCF OData Service, trying to filter by a string column throws the following NotSupportedException (StackTrace is a the end of the post):
"The expression (([10007].RoleName ?? "").ToLower().StartsWith("role1") == True) is not supported."
The problem seems to be that OData's Filter options do not support the null coalescence. The filter options description at odata.org says the following:
"Note: ISNULL or COALESCE operators are not defined. Instead, there is a null literal which can be used in comparisons."
After some digging in the source, we found where the coalesce expression is created and temporarily removed the call:
\Telerik.Web.Mvc\Infrastructure\Implementation\Filtering\FilterOperatorExtensions.cs ln 167:
var liftedToEmpty = ExpressionFactory.LiftStringExpressionToEmpty(stringExpression);
It's possible that similar problems with OData limitations lurk in other parts of the code, but we didn't dig further. It would be great if there is an official fix for the issue in next versions.
Regards,
Dimitar Milushev
P.S. StackTrace for the exceptions, if it's of any help:
at System.Data.Services.Client.ExpressionWriter.ExpressionToString(DataServiceContext context, Expression e)
at System.Data.Services.Client.UriWriter.VisitQueryOptionExpression(FilterQueryOptionExpression fqoe)
at System.Data.Services.Client.UriWriter.VisitQueryOptions(ResourceExpression re)
at System.Data.Services.Client.UriWriter.VisitResourceSetExpression(ResourceSetExpression rse)
at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.UriWriter.Translate(DataServiceContext context, Boolean addTrailingParens, Expression e, Uri& uri, Version& version)
at System.Data.Services.Client.DataServiceQueryProvider.Translate(Expression e)
at System.Data.Services.Client.DataServiceQuery`1.get_QueryComponents()
at System.Data.Services.Client.DataServiceRequest.GetQuerySetCount(DataServiceContext context)
at System.Data.Services.Client.DataServiceQueryProvider.ReturnSingleton[TElement](Expression expression)
at System.Data.Services.Client.DataServiceQueryProvider.Execute[TResult](Expression expression)
at Telerik.Web.Mvc.Extensions.QueryableExtensions.Count(IQueryable source) in C:\Users\developer-100\Documents\Telerik_Extensions_for_ASPNET_MVC_2011_2_712_OpenSource\Source\Telerik.Web.Mvc\Extensions\QueryableExtensions.cs:line 451
at Telerik.Web.Mvc.Extensions.QueryableExtensions.ToGridModel(IQueryable queryable, Int32 page, Int32 pageSize, IList`1 sortDescriptors, IEnumerable`1 filterDescriptors, IEnumerable`1 groupDescriptors) in C:\Users\developer-100\Documents\Telerik_Extensions_for_ASPNET_MVC_2011_2_712_OpenSource\Source\Telerik.Web.Mvc\Extensions\QueryableExtensions.cs:line 89
at Telerik.Web.Mvc.UI.GridDataProcessor.EnsureDataSourceIsProcessed() in C:\Users\developer-100\Documents\Telerik_Extensions_for_ASPNET_MVC_2011_2_712_OpenSource\Source\Telerik.Web.Mvc\UI\Grid\GridDataProcessor.cs:line 247
at Telerik.Web.Mvc.UI.GridDataProcessor.get_ProcessedDataSource() in C:\Users\developer-100\Documents\Telerik_Extensions_for_ASPNET_MVC_2011_2_712_OpenSource\Source\Telerik.Web.Mvc\UI\Grid\GridDataProcessor.cs:line 137
at Telerik.Web.Mvc.GridActionAttribute.OnActionExecuted(ActionExecutedContext filterContext) in C:\Users\developer-100\Documents\Telerik_Extensions_for_ASPNET_MVC_2011_2_712_OpenSource\Source\Telerik.Web.Mvc\UI\Grid\GridActionAttribute.cs:line 171
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
When the grid is bound to a WCF OData Service, trying to filter by a string column throws the following NotSupportedException (StackTrace is a the end of the post):
"The expression (([10007].RoleName ?? "").ToLower().StartsWith("role1") == True) is not supported."
The problem seems to be that OData's Filter options do not support the null coalescence. The filter options description at odata.org says the following:
"Note: ISNULL or COALESCE operators are not defined. Instead, there is a null literal which can be used in comparisons."
After some digging in the source, we found where the coalesce expression is created and temporarily removed the call:
\Telerik.Web.Mvc\Infrastructure\Implementation\Filtering\FilterOperatorExtensions.cs ln 167:
var liftedToEmpty = ExpressionFactory.LiftStringExpressionToEmpty(stringExpression);
It's possible that similar problems with OData limitations lurk in other parts of the code, but we didn't dig further. It would be great if there is an official fix for the issue in next versions.
Regards,
Dimitar Milushev
P.S. StackTrace for the exceptions, if it's of any help:
at System.Data.Services.Client.ExpressionWriter.ExpressionToString(DataServiceContext context, Expression e)
at System.Data.Services.Client.UriWriter.VisitQueryOptionExpression(FilterQueryOptionExpression fqoe)
at System.Data.Services.Client.UriWriter.VisitQueryOptions(ResourceExpression re)
at System.Data.Services.Client.UriWriter.VisitResourceSetExpression(ResourceSetExpression rse)
at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
at System.Data.Services.Client.UriWriter.Translate(DataServiceContext context, Boolean addTrailingParens, Expression e, Uri& uri, Version& version)
at System.Data.Services.Client.DataServiceQueryProvider.Translate(Expression e)
at System.Data.Services.Client.DataServiceQuery`1.get_QueryComponents()
at System.Data.Services.Client.DataServiceRequest.GetQuerySetCount(DataServiceContext context)
at System.Data.Services.Client.DataServiceQueryProvider.ReturnSingleton[TElement](Expression expression)
at System.Data.Services.Client.DataServiceQueryProvider.Execute[TResult](Expression expression)
at Telerik.Web.Mvc.Extensions.QueryableExtensions.Count(IQueryable source) in C:\Users\developer-100\Documents\Telerik_Extensions_for_ASPNET_MVC_2011_2_712_OpenSource\Source\Telerik.Web.Mvc\Extensions\QueryableExtensions.cs:line 451
at Telerik.Web.Mvc.Extensions.QueryableExtensions.ToGridModel(IQueryable queryable, Int32 page, Int32 pageSize, IList`1 sortDescriptors, IEnumerable`1 filterDescriptors, IEnumerable`1 groupDescriptors) in C:\Users\developer-100\Documents\Telerik_Extensions_for_ASPNET_MVC_2011_2_712_OpenSource\Source\Telerik.Web.Mvc\Extensions\QueryableExtensions.cs:line 89
at Telerik.Web.Mvc.UI.GridDataProcessor.EnsureDataSourceIsProcessed() in C:\Users\developer-100\Documents\Telerik_Extensions_for_ASPNET_MVC_2011_2_712_OpenSource\Source\Telerik.Web.Mvc\UI\Grid\GridDataProcessor.cs:line 247
at Telerik.Web.Mvc.UI.GridDataProcessor.get_ProcessedDataSource() in C:\Users\developer-100\Documents\Telerik_Extensions_for_ASPNET_MVC_2011_2_712_OpenSource\Source\Telerik.Web.Mvc\UI\Grid\GridDataProcessor.cs:line 137
at Telerik.Web.Mvc.GridActionAttribute.OnActionExecuted(ActionExecutedContext filterContext) in C:\Users\developer-100\Documents\Telerik_Extensions_for_ASPNET_MVC_2011_2_712_OpenSource\Source\Telerik.Web.Mvc\UI\Grid\GridActionAttribute.cs:line 171
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)