Volver al ranking

zzzprojects/System.Linq.Dynamic.Core

C#dynamic-linq.net

The .NET Standard / .NET Core version from the System Linq Dynamic functionality.

linqdynamicnetstandardcoresystemexpressionsqlentity-frameworklamdaefcoreentity-framework-core
Crecimiento de estrellas
Estrellas
1.7k
Forks
245
Crecimiento semanal
Issues
54
5001k1.5k
abr 2016sept 2019feb 2023jul 2026
README

System.Linq.Dynamic.Core

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:

var query = 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:

string cityName = "London";
int c = 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

Through Entity Framework Extensions and Dapper Plus, we actively sponsor and help key open-source libraries grow.

Entity Framework Extensions

Dapper Plus


:exclamation: Breaking changes

v1.3.0

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:

[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 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.


Info

Project  
  Chat Gitter
  Issues GitHub issues
Quality  
  CI Workflow CI Workflow
  SonarCloud Quality Gate Status
NuGet  
  System.Linq.Dynamic.Core NuGet
  EntityFramework.DynamicLinq NuGet
  Microsoft.EntityFrameworkCore.DynamicLinq NuGet
  Z.EntityFramework.Classic.DynamicLinq NuGet
  Z.DynamicLinq.SystemTextJson NuGet
  Z.DynamicLinq.NewtonsoftJson NuGet

Development Details

Frameworks

The following frameworks are supported:

  • net35, net40, net45, net46 and up
  • netstandard1.3, netstandard2.0 and netstandard2.1
  • netcoreapp3.1, net5.0, net6.0, net7.0, net8.0 and net9.0
  • uap10.0

Fork details

This fork takes the basic library to a new level. Also adds unit tests to help ensure that it works properly.

Some background: I forked from https://github.com/NArnott/System.Linq.Dynamic and added some more functionality there.
My fork is still visible on github [https://github.com/StefH/System.Linq.Dynamic], however I decided to start a new project + NuGet to avoid confusion and create the project according to the new VS2017 + .NET Core rules / standards.

However, currently there are multiple nuget packages and projects available:

Project NuGet Author Comment
kahanu/System.Linq.Dynamic System.Linq.Dynamic @kahanu -
kavun/System.Linq.Dynamic.3.5 System.Linq.Dynamic.3.5/ @kavun only 3.5 and VB.NET
NArnott/System.Linq.Dynamic System.Linq.Dynamic.Library @NArnott removed from github + nuget ?
dynamiclinq.codeplex - dialectsoftware -
dynamic-linq - scottgu -

Contribute

The best way to contribute is by spreading the word about the library:

  • Blog it
  • Comment it
  • Star it
  • Share it

A HUGE THANKS for your help.

More Projects

To view all our free and paid projects, visit our website ZZZ Projects.

Repositorios relacionados
neuecc/UniRx

Reactive Extensions for Unity

C#MIT Licenseunirxunity
7.3k885
ldqk/Masuit.Tools

全龄段友好的C#万能工具库,码数吐司库,包含一些常用的操作类,大都是静态类,加密解密,反射操作,权重随机筛选算法,分布式短id,表达式树,linq扩展,文件压缩,多线程下载,硬件信息,字符串扩展方法,日期时间扩展操作,中国农历,大文件拷贝,图像裁剪,验证码,断点续传,集合扩展、Excel导出等常用封装。诸多功能集一身,代码量不到2MB!

C#MIT Licenselambdareflection
masuit.tools
6.2k1.3k
AngleSharp/AngleSharp

:angel: The ultimate angle brackets parser library parsing HTML5, MathML, SVG and CSS to construct a DOM based on the official W3C specifications.

C#MIT Licenseanglesharpdom
anglesharp.github.io
5.5k593
Cysharp/ZLinq

Zero allocation LINQ with LINQ to Span, LINQ to SIMD, and LINQ to Tree (FileSystem, JSON, GameObject, etc.) for all .NET platforms and Unity, Godot.

C#MIT Licenselinqc-sharp
5.2k210
morelinq/MoreLINQ

Extensions to LINQ to Objects

C#Apache License 2.0linqdotnet
morelinq.github.io
3.8k418
ahmetb/go-linq

.NET LINQ capabilities in Go

GoGo ModulesApache License 2.0golinq
godoc.org/github.com/ahmetb/go-linq
3.7k225
stevencohn/OneMore

A OneNote add-in with simple, yet powerful and useful features

C#Mozilla Public License 2.0onenoteaddin
3.4k255
linq2db/linq2db

Linq to database provider.

C#MIT Licenselinqdatabase
3.3k478
nhibernate/nhibernate-core

NHibernate Object Relational Mapper

C#GNU Lesser General Public License v2.1nhibernatec-sharp
nhibernate.info
2.2k933
zio/zio-quill

Compile-time Language Integrated Queries for Scala

ScalaApache License 2.0databasescala
zio.dev/zio-quill
2.2k352
mihaifm/linq

linq.js - LINQ for JavaScript

JavaScriptnpmMIT Licenselinqjavascript
1.7k231
nhibernate/fluent-nhibernate

Fluent NHibernate!

C#BSD 3-Clause "New" or "Revised" Licensenhibernatefluent-api
1.7k677