Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/System.Linq.Dynamic.Core/ExpressionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ Expression ParseMemberAccess(Type type, Expression instance)
throw ParseError(errorPos, Res.NoApplicableMethod, id, GetTypeName(type));
case 1:
MethodInfo method = (MethodInfo)mb;
if (!IsPredefinedType(method.DeclaringType))
if (!IsPredefinedType(method.DeclaringType) && !(method.IsPublic && IsPredefinedType(method.ReturnType)))
throw ParseError(errorPos, Res.MethodsAreInaccessible, GetTypeName(method.DeclaringType));

if (method.ReturnType == typeof(void))
Expand Down
11 changes: 11 additions & 0 deletions test/System.Linq.Dynamic.Core.Tests/ExpressionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public void ExpressionTests_SkipAndTake()
}
}

[Fact]
public void ExpressionTests_Method()
{
var samples1 = User.GenerateSampleModels(3).AsQueryable();
var samples2 = User.GenerateSampleModels(3).ToArray();

var result = samples1.Where("TestMethod(@0)", samples2);

Assert.Equal(samples1.Count(), result.Count());
}

[Fact]
public void ExpressionTests_StringConcatenation()
{
Expand Down
5 changes: 5 additions & 0 deletions test/System.Linq.Dynamic.Core.Tests/Helpers/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class User

public List<Role> Roles { get; set; }

public bool TestMethod(User other)
{
return true;
}

public static IList<User> GenerateSampleModels(int total, bool allowNullableProfiles = false)
{
var list = new List<User>();
Expand Down