Skip to content

Commit 17ea732

Browse files
FIX method without parameter: #432
1 parent d8a8a7a commit 17ea732

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Z.Dynamic.Core.Lab/Program.cs

+15-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Linq.Dynamic.Core;
5+
using System.Linq.Expressions;
56
using Newtonsoft.Json;
67

78
namespace Z.Dynamic.Core.Lab
89
{
910
class Program
1011
{
11-
static void Main(string[] args)
12-
{
12+
public class Foo
13+
{
14+
public string? Bar { get; set; }
15+
public string? Baz() => "zzz";
16+
}
17+
18+
static void Main(string[] args)
19+
{
20+
var expression = "np(Bar.Length)";
21+
22+
var results = (new List<Foo>() { new Foo()}).AsQueryable().Select("np(Baz().Length)").ToDynamicList();
23+
24+
25+
1326

1427
Request_LambdaAddFunc.Execute();
1528

src/System.Linq.Dynamic.Core/Parser/ExpressionHelper.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ private List<Expression> CollectExpressions(bool addSelf, Expression sourceExpre
323323
break;
324324

325325
case MethodCallExpression methodCallExpression:
326-
expression = methodCallExpression.Arguments.First();
326+
// FIX method without parameter: https://github.com/zzzprojects/System.Linq.Dynamic.Core/issues/432
327+
expression = methodCallExpression.Arguments.FirstOrDefault();
327328
expressionRecognized = true;
328329
break;
329330

0 commit comments

Comments
 (0)