Use the extension method in a DynamicLinq query

I want to extend the Telerik RadGrid filter behavior. If the user, for example, filters the grid with the next word "michele", he should also return rows that include "michèle". This is not supported on RadGrid TV. Therefore, I wrote an extension method for the String type: public static bool IsSqlLikeMatch( this string input, string pattern ) { [...] }

As a second step, I replaced FilterExpression RadGrid as follows:

 this.MasterTableView.FilterExpression.Replace( "Contains", "IsSqlLikeMatch" ); 

But unfortunately, I get the following error message:

There is no applicable IsSqlLikeMatch method in type 'String'

Telerik RadGrid uses DynamicLinq. Therefore, therefore, my question is: “Can I use extension methods in DynamicLinq”? And how to do it?

Edit 09/09/2011: I contacted Telerik support and this was their answer:

Unfortunately, you could not extend the dynamic linq functions included with Telerik.Web.UI.dll. Thus, your changes to the DynamicLinq class will not use the ExpressionParser used inside RadControls. However, you can try to modify the Dynamic Linq library and perform selective filtering by getting the filter expression from the RadGrid analysis and passing them to the modified Dynamic Linq class method and associating RadGrid with the returned data. I have attached a small sample that demonstrates how to use RadGrid filters / sorts to filter, sort, and page through an ObjectDataSource.

+4
source share
1 answer

To use the extension method, you must have a using directive for the namespace of the class in which you defined the extension method.

So try putting your class in a namespace and add using for it.

Also, make sure that this class is defined as public static.

0
source

All Articles