Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Methods on type 'MyClass' are not accessible' #689

Closed
nowire opened this issue Mar 9, 2023 · 3 comments
Closed

'Methods on type 'MyClass' are not accessible' #689

nowire opened this issue Mar 9, 2023 · 3 comments
Assignees

Comments

@nowire
Copy link

nowire commented Mar 9, 2023

Dear,

With the old version (1.2.25) of the library I could call methods of the class in the order function. With the new version I get an error that the method is not accessible.

IEnumerable<PilotWithCO> pilotwithcolist = pilotwithcolist.AsQueryable().Where(where).OrderBy(order).ToList();

in order string I have, for example: "PenaltyTotal ascending, GetCOPenalty(0,2) ascending, GetCOPenalty(0,3) ascending"

where GetCOPenalty(0,2) is a public method of PilotWithCO class

System.Linq.Dynamic.Core.Exceptions.ParseException: 'Methods on type 'PilotWithCO' are not accessible'

@piotrroda
Copy link

I have the same exception after bumping to 1.3.1 version
System.Linq.Dynamic.Core.Exceptions.ParseException : Methods on type 'IInnerSlsRoleProxy' are not accessible

@StefH StefH self-assigned this Mar 10, 2023
@StefH
Copy link
Collaborator

StefH commented Mar 10, 2023

#690

@StefH
Copy link
Collaborator

StefH commented Mar 12, 2023

Breaking changes

v1.3.0

A breaking change is introduced in version 1.3.0 which is related to calling methods on classes.
Due to security reasons, it's now only allowed to call methods on the standard predefined classes like (bool, int, string ...).
If you want to call a method on an own custom class, annotate that class with the DynamicLinqType.
Example:

[DynamicLinqType]
public class MyCustomClass
{
    public int GetAge(int x) => x;
}

If it's not possible to add that attribute, you need to implement a custom CustomTypeProvider and set this to the ParsingConfig and provide that config to the dynamic call.

@StefH StefH pinned this issue Mar 12, 2023
@zzzprojects zzzprojects locked as resolved and limited conversation to collaborators Mar 12, 2023
@StefH StefH closed this as completed Mar 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants