views:

113

answers:

1

Hi all.

I have a problem using Telerik RadGrid. When I apply a filter on a data column, I use the filter expression as a Linq expression. So (server side) I parse it with Dynamic Linq (from MIcrosoft LINQ examples) in NeedDataSource handler. The problem is that when I specify "Start With" as a filter, I receive the following as "Linq expression":

(iif(Name == null, "", Name).ToString().StartsWith("A"))

What is "iif"???? What corresponds to "iif"???? Usage is obvious: handling nulls....

The strange thing is that when I apply the filter on a grid that loads data from web services and not from server side callback, all works and this issue don't raise. Two ways, two parsing function, not only a common one.

Any idea? Thanks in advance

A: 

In Dynamic LINQ iif(x,y,z) is another syntax for the ternary if x ? y : z, the same name was used in VB for some time ("Immediate IF")

In this case, it looks like it a null-coalescing operator ??, but it seems that Dynamic LINQ doesn't support that

(Name ?? string.Empty).ToString().StartsWith("A")

Maybe try to substitute the iif with the ternary notation? Can you clarify what is the exact error that happens?

Yacoder
Yes, but the problem is that RadGrid specify iif, not me! This is the problem!
Marco Parenzan
@Marco: what is the problem with that "iif"? It should be easily parsed by Dynamic LINQ... why do you want to get rid of it?
Yacoder
DynamicLinq code (from Microsoft examples - http://msdn.microsoft.com/en-us/vcsharp/bb894665.aspx) does not parse iif. That's the problem.
Marco Parenzan
@Marco: that's strange... iif() is in the supported operations table, open the Dynamic Expressions.html from the link you gave
Yacoder
You are right, I have done a mistaken question. The problem is not on iif (sorry! :)), but on consequent ToString(). Iif evaluated generically as an object, not a string. ToString() is mandatory, but SQL provider does not know how to translate this!
Marco Parenzan
@Marco: What will happen if you remove the "ToString()" from the string filter? Are you sure it fails?
Yacoder
I cannot remove it! The code is generated by Telerik RadGrid and I'm not able to find any way to intercept the code generation...
Marco Parenzan