LogicBuilder.Expressions.Utils 6.0.3

Prefix Reserved
dotnet add package LogicBuilder.Expressions.Utils --version 6.0.3                
NuGet\Install-Package LogicBuilder.Expressions.Utils -Version 6.0.3                
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="LogicBuilder.Expressions.Utils" Version="6.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LogicBuilder.Expressions.Utils --version 6.0.3                
#r "nuget: LogicBuilder.Expressions.Utils, 6.0.3"                
#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 LogicBuilder.Expressions.Utils as a Cake Addin
#addin nuget:?package=LogicBuilder.Expressions.Utils&version=6.0.3

// Install LogicBuilder.Expressions.Utils as a Cake Tool
#tool nuget:?package=LogicBuilder.Expressions.Utils&version=6.0.3                

Build LINQ Expressions Dynamically

Create complex expressions from single descriptor objects.

To use:

        public void BuildFilter()
        {
            IConfigurationProvider config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile<ExpressionOperatorsMappingProfile>();
            });
            IMapper mapper = config.CreateMapper();

            Expression<Func<Product, bool>> filter = GetFilterExpression<Product>
            (
                //$it => $it.AlternateAddresses.Any(address => (address.City == "Redmond"))
                new FilterLambdaDescriptor
                (
                    new AnyDescriptor
                    (
                        new MemberSelectorDescriptor("AlternateAddresses", new ParameterDescriptor("$it")),
                        new EqualsBinaryDescriptor
                        (
                            new MemberSelectorDescriptor("City", new ParameterDescriptor("address")),
                            new ConstantDescriptor("Redmond")
                        ),
                        "address"
                    ),
                    typeof(Product),
                    "$it"
                )
            );

            Expression<Func<T, bool>> GetFilterExpression<T>(FilterLambdaDescriptor descriptor)
                => (Expression<Func<T, bool>>)mapper.Map<FilterLambdaOperator>
                (
                    descriptor,
                    opts => opts.Items["parameters"] = new Dictionary<string, ParameterExpression>()
                ).Build();
        }

        public void BuildSelector()
        {
            IConfigurationProvider config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile<ExpressionOperatorsMappingProfile>();
            });
            IMapper mapper = config.CreateMapper();

            Expression<Func<IQueryable<Category>, Category>> selector = GetSelectorExpression<IQueryable<Category>, Category>
            (
                //$it => $it.FirstOrDefault(a => (a.CategoryID == -1))
                new SelectorLambdaDescriptor
                (
                    new FirstOrDefaultDescriptor
                    (
                        new ParameterDescriptor("$it"),
                        new EqualsBinaryDescriptor
                        (
                            new MemberSelectorDescriptor("CategoryID", new ParameterDescriptor("a")),
                            new ConstantDescriptor(-1)
                        ),
                        "a"
                    ),
                    typeof(IQueryable<Category>),
                    typeof(Category),
                    "$it"
                )
            );
            
            Expression<Func<T, TResult>> GetSelectorExpression<T, TResult>(SelectorLambdaDescriptor descriptor)
                => (Expression<Func<T, TResult>>)mapper.Map<SelectorLambdaOperator>
                (
                    descriptor,
                    opts => opts.Items["parameters"] = new Dictionary<string, ParameterExpression>()
                ).Build();
        }

ExpressionOperatorsMappingProfile is a mapping profile from LogicBuilder.EntityFrameworkCore.SqlServer.

For serializable descriptors, replace cfg.AddProfile<ExpressionOperatorsMappingProfile>(); with a custom mapping profile with serializable descriptors.

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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework 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 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 (6)

Showing the top 5 NuGet packages that depend on LogicBuilder.Expressions.Utils:

Package Downloads
AutoMapper.AspNetCore.OData.EFCore

Creates LINQ expressions from ODataQueryOptions and executes the query.

AutoMapper.AspNetCore.OData.EF6

Creates LINQ expressions from ODataQueryOptions and executes the query.

AutoMapper.AspNet.OData.EF6

Creates LINQ expressions from ODataQueryOptions and executes the query.

LogicBuilder.Expressions.EntityFrameworkCore

Augments LogicBuilder.Expressions.Utils with LINQ queries specific to EF Core.

LogicBuilder.EntityFrameworkCore.SqlServer

Given an EF Core DBContext, LogicBuilder.EntityFrameworkCore.SqlServer uses AutoMapper configurations to support CRUD operations using the DTO objects.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on LogicBuilder.Expressions.Utils:

Repository Stars
AutoMapper/AutoMapper.Extensions.OData
Creates LINQ expressions from ODataQueryOptions and executes the query.
Version Downloads Last updated
6.0.3 38,365 11/3/2024
6.0.2 538 8/11/2024
6.0.1 1,689 3/28/2024
6.0.0 738,709 12/27/2023
5.0.12 2,148 10/14/2023
5.0.11 100 10/14/2023
5.0.10 153,303 8/15/2023
5.0.9 683 7/16/2023
5.0.8 731 5/10/2023
5.0.7 4,223 10/1/2022
5.0.6 534,951 6/16/2022
5.0.4 694,066 4/15/2022
5.0.3 1,357 4/15/2022
5.0.2 4,766 12/24/2021
5.0.1 979 12/14/2021
5.0.0 23,469 12/14/2021
4.1.3 1,824 9/8/2021
4.1.3-preview.3 195 9/7/2021
4.1.3-preview.2 159 8/26/2021
4.1.3-preview.1 174 8/23/2021
4.1.3-preview.0 174 8/7/2021
4.1.2 134,893 5/11/2021
4.1.1 147,584 2/20/2021
4.1.1-preview.2 189 2/8/2021
4.1.1-preview.0 172 2/5/2021
4.1.0 832 1/13/2021
4.0.2 92,409 9/16/2020
4.0.1 3,242 9/8/2020
4.0.1-preview.1 283 9/4/2020
4.0.1-preview.0 474 8/26/2020
4.0.0 3,286 7/23/2020
4.0.0-preview02 838 7/20/2020
4.0.0-preview01 948 7/17/2020
2.0.0 10,456 8/27/2019
1.0.0 3,667 12/30/2018
1.0.0-preview16 1,279 9/17/2018
1.0.0-preview15 1,207 9/17/2018

Expanding primitive lists by default.