You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a .NET Core / Standard port of the Microsoft assembly for the .Net 4.0 Dynamic language functionality.
Overview
With this library it's possible to write Dynamic LINQ queries (string based) on an IQueryable:
varquery=db.Customers.Where("City == @0 and Orders.Count >= @1","London",10).OrderBy("CompanyName").Select("new(CompanyName as Name, Phone)");
Interpolated strings are supported on .NET 4.6(and above), .NET Core 2.1(and above), .NET Standard 1.3(and above) and UAP 10.0(and above).
For example:
stringcityName="London";intc=10;db.Customers.WhereInterpolated($"City == {cityName} and Orders.Count >= {c}");
Sponsors
ZZZ Projects owns and maintains System.Linq.Dynamic.Core as part of our mission to add value to the .NET community
A breaking change is introduced in this version 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:
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 all dynamic calls.
Or provide a list of additional types in the DefaultDynamicLinqCustomTypeProvider.cs.
v1.6.0
Change 1
It's not allowed anymore to call any methods on the object type. By default also the ToString and Equals methods are not allowed.
This is done to mitigate the risk of calling methods on the object type which could lead to security issues (CVE-2024-51417).
To allow these methods set AllowEqualsAndToStringMethodsOnObject to true in the ParsingConfig and provide that config to all dynamic calls.
Change 2
By default the RestrictOrderByToPropertyOrField is now set to true in the ParsingConfig.
Which means that only properties and fields can be used in the OrderBy / ThenBy.
This is done to mitigate the risk of calling methods or other expressions in the OrderBy / ThenBy which could lead to security issues.
To allow these methods set RestrictOrderByToPropertyOrField to false in the ParsingConfig and provide that config to all dynamic calls.
Change 3
The DefaultDynamicLinqCustomTypeProvider has been changed to only return types which have the [DynamicLinqType] attribute applied.
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 all dynamic calls.
Or provide a list of additional types in the DefaultDynamicLinqCustomTypeProvider.cs.