BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions
1.10.0
dotnet add package BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions --version 1.10.0
NuGet\Install-Package BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions -Version 1.10.0
<PackageReference Include="BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions" Version="1.10.0" />
<PackageVersion Include="BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions" Version="1.10.0" />
<PackageReference Include="BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions" />
paket add BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions --version 1.10.0
#r "nuget: BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions, 1.10.0"
#:package BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions@1.10.0
#addin nuget:?package=BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions&version=1.10.0
#tool nuget:?package=BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions&version=1.10.0
BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions
Strongly-typed attributes and enums used by the Predicate Generator.
These annotations are applied to filter DTOs so a source generator can emit ToPredicate() and HasFilter() methods.
Target Frameworks:
netstandard2.0
C# Language Version: C# 11+ (required for generic attributes)
Contents
GeneratePredicateAttribute<TEntity>StringFilterAttributeNumericFilterAttributeTemporalFilterAttributeBooleanFilterAttributeComparisonOperatorenum
Installation
Install it in the app project:
dotnet add package BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions
Usage
Annotate your filter DTO with [GeneratePredicate<TEntity>] and mark each filterable property with the respective attribute.
using BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions;
[GeneratePredicate<Domain.UserRecord>]
public partial class UserFilterDto
{
[StringFilter(TargetProperty = nameof(Domain.UserRecord.Name), Order = 1)]
public string? Name { get; init; }
[StringFilter(TargetProperty = nameof(Domain.UserRecord.Email), Order = 2)]
public string? Email { get; init; }
[NumericFilter(TargetProperty = nameof(Domain.UserRecord.Age),
Operator = ComparisonOperator.GreaterThanOrEqual, Order = 3)]
public int? MinimumAge { get; init; }
[TemporalFilter(TargetProperty = nameof(Domain.UserRecord.CreatedAt),
Operator = ComparisonOperator.LessThanOrEqual, Order = 4)]
public DateTime? CreatedUntil { get; init; }
[BooleanFilter(TargetProperty = nameof(Domain.UserRecord.Active), Order = 5)]
public bool? Active { get; init; }
}
The DTO must be
partial. The generator adds the methods into the same type.
Behavior
Generated methods
Generated methods
Expression<Func<TEntity, bool>> ToPredicate()bool HasFilter()
HasFilter() returns true if at least one annotated property holds a non-null value.
ToPredicate() returns entity => true when all annotated values are null; otherwise it combines only the provided filters with logical AND.
String wildcards
When the string value contains %, the pattern is passed to the database (LIKE):
- No
%→ equality (field == value) - Ends with
%→ database pattern (e.g.,value%) - Starts with
%→ database pattern (e.g.,%value) %in the middle or both sides → database pattern (e.g.,%val%ue%)
This relies on the generator’s provider-aware output (see the Generator README).
Numeric and temporal operators
NumericFilterAttribute and TemporalFilterAttribute accept Operator: ComparisonOperator:
Equal,GreaterThan,LessThan,GreaterThanOrEqual,LessThanOrEqual.
Boolean properties
Always compared by equality.
Query Order
Usually, the where field orders matters - for database index usage.
Filters are composed by Order (if specified). Otherwise, DTO declaration order is used.
Requirements
C# 11+ (for generic attributes)
Works with EF Core 6/7/8+ (generator handles provider-specific differences)
| 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on BlogDoFT.Libs.EntityFramework.CodeGenerator.Abstractions:
| Package | Downloads |
|---|---|
|
BlogDoFT.Libs.EntityFramework.CodeGenerator
EF Core predicate source generator with provider-aware LIKE/ILIKE support. |
GitHub repositories
This package is not used by any popular GitHub repositories.