Linq.Expression.Optimizer 1.0.13

There is a newer version of this package available.
See the version list below for details.
dotnet add package Linq.Expression.Optimizer --version 1.0.13
NuGet\Install-Package Linq.Expression.Optimizer -Version 1.0.13
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Linq.Expression.Optimizer" Version="1.0.13" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Linq.Expression.Optimizer --version 1.0.13
#r "nuget: Linq.Expression.Optimizer, 1.0.13"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Linq.Expression.Optimizer as a Cake Addin
#addin nuget:?package=Linq.Expression.Optimizer&version=1.0.13

// Install Linq.Expression.Optimizer as a Cake Tool
#tool nuget:?package=Linq.Expression.Optimizer&version=1.0.13

Issue Stats Issue Stats

Linq.Expression.Optimizer

Lightweight optimizer of System.Linq.Expression expressions. Just basic boolean algebra and reductions, constant and tuple/anonymous type eliminations. For side-effect free Expressions. No compilation-subjective optimizations. This is meant to be used with expressions that are not compiled but transferred to other domain.

Supported frameworks: Net 3.5, Net 4.5-... (and Mono), .NET Standard 1.6 (so also .NET Core)

Supported optimizations

Example as a quote. There are various other cases also.

  • Replace constants comparisons: 3 < 4 -> true
  • Remove anonymous types: new AnonymousObject(Item1 = x, Item2 = "").Item1 --> x
  • Cut not used condition: if false then x else y -> y
  • Remove not: not(false) -> true
  • Binary tree balancing: a or (b or (c or (d or (e or (f or (g or h)))))) -> ((a or b) or (c or d)) or ((e or f) or (g or h))
  • Captured closure constant ("free variable") evaluation: y = 3 and (y + x) -> (3 + x)
  • Execute simple math: 5 * 3 -> 15
  • Boolean algebra reductions:
    • gather (x or y) and (x or z) -> x or (y and z)
    • identity false or y -> y
    • annihilate true or x -> true
    • absorb x and (x or y) -> x
    • idempotence y or y -> y
    • complement x and not(x) -> false
    • doubleNegation not(not(y)) -> y
    • deMorgan not(x) and not(y) -> not(x or y)

Background

This is a side-track from SQLProvider, excelent tool that is kind of OR-mapper with auto-generated objects, so it compiles any databases to .NET-language, and works fast on design time in Visual Studio or other editors.

But I needed better SQL-queries. So this optimses .NET LINQ-expressions. These expressions were not ment to be compiled so Nessos LinqOptimizer was not the right tool. I thought that .NET would optimize these automatically, but no.

Read the Getting started tutorial to learn more.

Documentation: http://thorium.github.io/Linq.Expression.Optimizer

Maintainer(s)

If you want more optimizations, please feel free to send PRs!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.6 is compatible.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Linq.Expression.Optimizer:

Package Downloads
SpacetimeDB.Runtime

The SpacetimeDB Runtime implements the database runtime bindings for writing SpacetimeDB modules in C#.

SpeedyCourse.Entities

Package Description

XSpecification.Linq

XSpecification is an implementation of Specification pattern for Linq and Elasticsearch

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Linq.Expression.Optimizer:

Repository Stars
scottksmith95/LINQKit
LINQKit is a free set of extensions for LINQ to SQL and Entity Framework power users.
Version Downloads Last updated
1.0.21 448 4/5/2024
1.0.20 143 4/2/2024
1.0.18 868 3/11/2024
1.0.16 8,672 10/8/2023
1.0.15 12,003 3/7/2023
1.0.13 179,810 5/27/2019
1.0.12 33,989 8/31/2018
1.0.11 29,135 1/1/2018
1.0.10 1,386 1/1/2018
1.0.9 25,682 6/5/2017
1.0.8 1,591 5/10/2017
1.0.7 28,891 10/7/2016
1.0.6 1,407 10/6/2016
1.0.5 1,358 10/5/2016
1.0.4 1,554 10/3/2016
1.0.3 1,590 8/30/2016
1.0.2 1,404 8/30/2016
1.0.1 1,325 8/30/2016
1.0.0 1,404 8/27/2016

Look inside a WhereSelectEnumerableIterator, #9