[英]System.Linq.Dynamic using ?? c# operador
I would like to use the ?? 我想使用?? operator, and thus avoid large chains have to use the IIF operator. 运算符,从而避免大型连锁店不得不使用IIF运算符。
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. 也许还有另一种方法可以做到这一点。
See http://weblogs.asp.net/scottgu/dynamic-linq-part-1-using-the-linq-dynamic-query-library 参见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 和https://msdn.microsoft.com/zh-CN/vstudio/bb894665.aspx
Dynamic linq takes a string and converts it to the Linq equivalent. 动态linq接受一个字符串并将其转换为Linq等效项。 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.... tokenId枚举说明了很多事情,我刚刚打开解析器并看到了...。
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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.