Example of SQL being sent to SQL Server:
SELECT [Extent1].[ID] AS [ID], [Extent1].[Capture Date] AS [Capture Date], [Extent1].[Item Sequence Number] AS [Item Sequence Number],
FROM [dbo].[Images] AS [Extent1]
WHERE ((LOWER([Extent1].[Account Number])) = (LOWER('112233'))) OR ((LOWER([Extent1].[Account Number]) IS NULL) AND (LOWER('112233') IS NULL))
I am using hte latest version of Telerik UI for MVC and EF 6. The datasource code in the controller is:
public ActionResult Images_Read([DataSourceRequest]DataSourceRequest request)
{
return this.Json(this._repository.Images.ToDataSourceResult(request));
}
Can I prevent Telerik's grid from using t-sql's lower function?
7 Answers, 1 is accepted
Currently there is no built-in way to disable this behavior. This is done in order to support case insensitive filtering in all possible LINQ providers. A possible workaround is to use custom binding and implement the filtering in your own code. The UI for ASP.NET MVC sample application includes a runnable demo which you can check.
Regards,
Atanas Korchev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
In order to make it case-sensitive you can use filterable ignoreCase option:
http://docs.telerik.com/kendo-ui/api/aspnet-mvc/Kendo.Mvc.UI.Fluent/GridBoundColumnFilterableBuilder#methods-IgnoreCase(System.Boolean)
Regards,
Kostadin
Telerik by Progress
Hi,
with Kendo Grid version "2017.1.223" I have set IgnoreCase eg.: columns.Bound(c => c.CodResource).Title("CodResource").Filterable(filterable => filterable.IgnoreCase(true)).Width(180) but the sql that is sent to SQL server still use the "lower" function:
SQL Statement is:
select .....
from v_ResourceIndex
where lower(v_resource0_.CodResource) like ('bb'+'%')
Any advice about avoid use of lower(..) function in WHERE Clause which causes performance issue?
Regards,
Pietro.
If this is the SQL query generated by the Kendo UI methods, it is the built-in behavior as this is the part of the query which is making a case-insensitive search.
As my colleague, Atanas said in the first post, the option to modify this is to actually make custom filtering logic and the build the query programmatically without the built-in methods.
Apologies for the inconvenience this may have caused you.
Regards,
Stefan
Progress Telerik
Hi Stefan,
could you give me an example about filtering (not only about sorting or paging like here: https://docs.telerik.com/aspnet-mvc/helpers/grid/binding/custom-binding#custom-ajax-binding)
Thanks in advance.
Regards,
Pietro.
You probably have already seen this from my reply in your ticket but in case anyone else is looking for the same information, this demo shows an implementation that applies data operations manually, including filtering.
Regards,
Tsvetina
Progress Telerik
The demo linked by Tsvetina does not demonstrate custom filtering.
This line of code towards the bottom
data = data.Where(ExpressionBuilder.Expression<OrderViewModel>(filterDescriptors, false));
applies all of the filterDescriptors with a LOWER function in the database query.
Can this be customized to avoid the LOWER operation?
public static IQueryable<OrderViewModel> ApplyOrdersFiltering(this IQueryable<OrderViewModel> data,
IList<IFilterDescriptor> filterDescriptors)
{
if (filterDescriptors != null && filterDescriptors.Any())
{
data = data.Where(ExpressionBuilder.Expression<OrderViewModel>(filterDescriptors, false));
}
return data;
}