@@ -53,9 +53,8 @@ public class ExpressionParser
53
53
public string ItName { get ; private set ; } = KeywordsHelper . KEYWORD_IT ;
54
54
55
55
/// <summary>
56
- /// There was a problem when an expression contained multiple lambdas where
57
- /// the ItName was not cleared and freed for the next lambda. This variable
58
- /// stores the ItName of the last parsed lambda.
56
+ /// There was a problem when an expression contained multiple lambdas where the ItName was not cleared and freed for the next lambda.
57
+ /// This variable stores the ItName of the last parsed lambda.
59
58
/// Not used internally by ExpressionParser, but used to preserve compatibility of parsingConfig.RenameParameterExpression
60
59
/// which was designed to only work with mono-lambda expressions.
61
60
/// </summary>
@@ -269,17 +268,19 @@ private Expression ParseNullCoalescingOperator()
269
268
// => operator - Added Support for projection operator
270
269
private Expression ParseLambdaOperator ( )
271
270
{
272
- Expression expr = ParseOrOperator ( ) ;
271
+ var expr = ParseOrOperator ( ) ;
272
+
273
273
if ( _textParser . CurrentToken . Id == TokenId . Lambda && _it ? . Type == expr . Type )
274
274
{
275
275
_textParser . NextToken ( ) ;
276
- if ( _textParser . CurrentToken . Id == TokenId . Identifier || _textParser . CurrentToken . Id == TokenId . OpenParen )
276
+ if ( _textParser . CurrentToken . Id is TokenId . Identifier or TokenId . OpenParen )
277
277
{
278
278
var right = ParseConditionalOperator ( ) ;
279
279
return Expression . Lambda ( right , new [ ] { ( ParameterExpression ) expr } ) ;
280
280
}
281
281
_textParser . ValidateToken ( TokenId . OpenParen , Res . OpenParenExpected ) ;
282
282
}
283
+
283
284
return expr ;
284
285
}
285
286
@@ -1061,7 +1062,9 @@ private Expression ParseIt()
1061
1062
{
1062
1063
throw ParseError ( Res . NoItInScope ) ;
1063
1064
}
1065
+
1064
1066
_textParser . NextToken ( ) ;
1067
+
1065
1068
return _it ;
1066
1069
}
1067
1070
@@ -1784,6 +1787,12 @@ private Expression ParseMemberAccess(Type? type, Expression? expression, string?
1784
1787
_textParser . NextToken ( ) ;
1785
1788
}
1786
1789
1790
+ // Parse as Lambda
1791
+ if ( _textParser . CurrentToken . Id == TokenId . Lambda && _it ? . Type == type )
1792
+ {
1793
+ return ParseAsLambda ( id ) ;
1794
+ }
1795
+
1787
1796
if ( _textParser . CurrentToken . Id == TokenId . OpenParen )
1788
1797
{
1789
1798
var isStaticAccess = expression == null ;
@@ -1866,11 +1875,6 @@ private Expression ParseMemberAccess(Type? type, Expression? expression, string?
1866
1875
return _expressionHelper . ConvertToExpandoObjectAndCreateDynamicExpression ( expression ! , type , id ) ;
1867
1876
}
1868
1877
#endif
1869
- // Parse as Lambda
1870
- if ( _textParser . CurrentToken . Id == TokenId . Lambda && _it ? . Type == type )
1871
- {
1872
- return ParseAsLambda ( id ) ;
1873
- }
1874
1878
1875
1879
// This could be enum like "A.B.C.MyEnum.Value1" or "A.B.C+MyEnum.Value1".
1876
1880
//
@@ -2118,7 +2122,7 @@ private Expression ParseEnumerable(Expression instance, Type elementType, string
2118
2122
}
2119
2123
else
2120
2124
{
2121
- if ( new [ ] { "Concat" , "Contains" , "DefaultIfEmpty" , "Except" , "Intersect" , "Skip" , "Take" , "Union" } . Contains ( methodName ) )
2125
+ if ( new [ ] { "Concat" , "Contains" , "ContainsKey" , " DefaultIfEmpty", "Except" , "Intersect" , "Skip" , "Take" , "Union" } . Contains ( methodName ) )
2122
2126
{
2123
2127
args = new [ ] { instance , args [ 0 ] } ;
2124
2128
}
0 commit comments