System.Linq.Dynamic using ?? c# operador

c# dynamic-linq linq

Question

I would like to use the ?? operator, and thus avoid large chains have to use the IIF operator.

Example:

customers.Select ("new (CompanyName as Name, Phone)");

customers.Select ("new (CompanyName as Name, iif (Phone = null, string.Empty, Phone) as Phone)");

customers.Select ("new (CompanyName as Name, (Phone ?? string.Empty) as Phone)");

Or maybe there's another way to do this.

1
1
9/9/2015 10:45:46 PM

Popular Answer

See http://weblogs.asp.net/scottgu/dynamic-linq-part-1-using-the-linq-dynamic-query-library
and https://msdn.microsoft.com/en-US/vstudio/bb894665.aspx

Dynamic linq takes a string and converts it to the Linq equivalent. You can even get source code form links and check the parse of string options.

I just checked the library and think it would have very little chance of doing what you want.
the tokenId enum says a lot about what is possible I just opened the Parser and saw this....

 private enum TokenId {
        Unknown,
        End,
        Identifier,
        StringLiteral,
        IntegerLiteral,
        RealLiteral,
        Exclamation,
        Percent,
        Amphersand,
        OpenParen,
        CloseParen,
        Asterisk,
        Plus,
        Comma,
        Minus,
        Dot,
        Slash,
        Colon,
        LessThan,
        Equal,
        GreaterThan,
        Question,
        OpenBracket,
        CloseBracket,
        Bar,
        ExclamationEqual,
        DoubleAmphersand,
        LessThanEqual,
        LessGreater,
        DoubleEqual,
        GreaterThanEqual,
        DoubleBar
    }
1
9/9/2015 11:06:00 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow