Skip to content

Commit

Permalink
FIX method without parameter: #432
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMagnan committed Oct 24, 2020
1 parent d8a8a7a commit 17ea732
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
17 changes: 15 additions & 2 deletions Z.Dynamic.Core.Lab/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using Newtonsoft.Json;

namespace Z.Dynamic.Core.Lab
{
class Program
{
static void Main(string[] args)
{
public class Foo
{
public string? Bar { get; set; }
public string? Baz() => "zzz";
}

static void Main(string[] args)
{
var expression = "np(Bar.Length)";

var results = (new List<Foo>() { new Foo()}).AsQueryable().Select("np(Baz().Length)").ToDynamicList();




Request_LambdaAddFunc.Execute();

Expand Down
3 changes: 2 additions & 1 deletion src/System.Linq.Dynamic.Core/Parser/ExpressionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ private List<Expression> CollectExpressions(bool addSelf, Expression sourceExpre
break;

case MethodCallExpression methodCallExpression:
expression = methodCallExpression.Arguments.First();
// FIX method without parameter: https://github.com/zzzprojects/System.Linq.Dynamic.Core/issues/432
expression = methodCallExpression.Arguments.FirstOrDefault();
expressionRecognized = true;
break;

Expand Down

0 comments on commit 17ea732

Please sign in to comment.