LogicBuilder.Expressions.Utils
7.0.0
Prefix Reserved
dotnet add package LogicBuilder.Expressions.Utils --version 7.0.0
NuGet\Install-Package LogicBuilder.Expressions.Utils -Version 7.0.0
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="7.0.0" />
paket add LogicBuilder.Expressions.Utils --version 7.0.0
#r "nuget: LogicBuilder.Expressions.Utils, 7.0.0"
// Install LogicBuilder.Expressions.Utils as a Cake Addin #addin nuget:?package=LogicBuilder.Expressions.Utils&version=7.0.0 // Install LogicBuilder.Expressions.Utils as a Cake Tool #tool nuget:?package=LogicBuilder.Expressions.Utils&version=7.0.0
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 | Versions 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. |
-
.NETStandard 2.0
- LogicBuilder.Structures (>= 7.0.0)
- Microsoft.CSharp (>= 4.7.0)
- System.Reflection.Emit (>= 4.7.0)
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 |
---|---|---|
7.0.0 | 1,649 | 11/25/2024 |
6.0.3 | 112,229 | 11/3/2024 |
6.0.2 | 547 | 8/11/2024 |
6.0.1 | 2,059 | 3/28/2024 |
6.0.0 | 779,442 | 12/27/2023 |
5.0.12 | 2,231 | 10/14/2023 |
5.0.11 | 104 | 10/14/2023 |
5.0.10 | 155,536 | 8/15/2023 |
5.0.9 | 688 | 7/16/2023 |
5.0.8 | 736 | 5/10/2023 |
5.0.7 | 4,366 | 10/1/2022 |
5.0.6 | 541,344 | 6/16/2022 |
5.0.4 | 722,742 | 4/15/2022 |
5.0.3 | 1,361 | 4/15/2022 |
5.0.2 | 4,799 | 12/24/2021 |
5.0.1 | 983 | 12/14/2021 |
5.0.0 | 23,657 | 12/14/2021 |
4.1.3 | 1,828 | 9/8/2021 |
4.1.3-preview.3 | 199 | 9/7/2021 |
4.1.3-preview.2 | 161 | 8/26/2021 |
4.1.3-preview.1 | 176 | 8/23/2021 |
4.1.3-preview.0 | 176 | 8/7/2021 |
4.1.2 | 135,802 | 5/11/2021 |
4.1.1 | 148,081 | 2/20/2021 |
4.1.1-preview.2 | 191 | 2/8/2021 |
4.1.1-preview.0 | 174 | 2/5/2021 |
4.1.0 | 836 | 1/13/2021 |
4.0.2 | 93,158 | 9/16/2020 |
4.0.1 | 3,246 | 9/8/2020 |
4.0.1-preview.1 | 285 | 9/4/2020 |
4.0.1-preview.0 | 476 | 8/26/2020 |
4.0.0 | 3,566 | 7/23/2020 |
4.0.0-preview02 | 840 | 7/20/2020 |
4.0.0-preview01 | 950 | 7/17/2020 |
2.0.0 | 10,460 | 8/27/2019 |
1.0.0 | 3,671 | 12/30/2018 |
1.0.0-preview16 | 1,285 | 9/17/2018 |
1.0.0-preview15 | 1,213 | 9/17/2018 |
Supporting .NET 9.0.