AxaFrance.LdapFiltersToLambdaExpression
1.0.3
Prefix Reserved
dotnet add package AxaFrance.LdapFiltersToLambdaExpression --version 1.0.3
NuGet\Install-Package AxaFrance.LdapFiltersToLambdaExpression -Version 1.0.3
<PackageReference Include="AxaFrance.LdapFiltersToLambdaExpression" Version="1.0.3" />
paket add AxaFrance.LdapFiltersToLambdaExpression --version 1.0.3
#r "nuget: AxaFrance.LdapFiltersToLambdaExpression, 1.0.3"
// Install AxaFrance.LdapFiltersToLambdaExpression as a Cake Addin #addin nuget:?package=AxaFrance.LdapFiltersToLambdaExpression&version=1.0.3 // Install AxaFrance.LdapFiltersToLambdaExpression as a Cake Tool #tool nuget:?package=AxaFrance.LdapFiltersToLambdaExpression&version=1.0.3
AxaFrance.LdapFiltersToLambdaExpression
Translate ldap filters (string) to lambda expression. it is compatible with EFCore in order to generate an SQL query from an ldap filter
Usage
Configuration for EFCore
Cette configuration est requise seulement si vous souhaitez requeter dans un model de donnée SQL via EntityFramework.
EFCoreLike permet dans le cas d'EFCore d'utiliser la methode Like d'EntityFramework et non pas celle definit par defaut dans cette librairie
public class EFCoreLike : IFunction
{
public MethodInfo MethodInfo => this.DeclaringType.GetMethod(nameof(DbFunctionsExtensions.Like),
new[] { typeof(DbFunctions), typeof(string), typeof(string) })!;
public Type DeclaringType => typeof(DbFunctionsExtensions);
public string ExpressionPattern =>
$"{nameof(DbFunctionsExtensions)}.{this.MethodInfo.Name}({nameof(EF)}.{nameof(EF.Functions)}, {{0}},{{1}})";
}
EFCoreSoundex permet dans le cas d'EFCore d'utiliser une methode gerant une approximationcompatible avec SQL et non pas celle definit par defaut dans cette librairie
public class EFCoreSoundex : IFunction
{
public MethodInfo MethodInfo => this.DeclaringType.GetMethod(nameof(SampleDbContext.Soundex),
new[] { typeof(string) })!;
public Type DeclaringType => typeof(SampleDbContext);
public string ExpressionPattern => $"{this.DeclaringType.FullName}.{this.MethodInfo.Name}({{0}})";
}
Il est important d'ajouter les namespaces neccessaire a la generation de lanbda, ici le namespace EntityFrameworkCore
services.LdapFiltersToLambdaConfigure(option =>
{
option.LikeFunction(new EFCoreLike())
.ApproximateFunction(new EFCoreSoundex())
.AddNamespaces($"{nameof(Microsoft)}.{nameof(Microsoft.EntityFrameworkCore)}");
})
Queries
Where Query
var whereQuery = queryable.ByLdapFilterAsync("(job=dirige*)");
Specify Query
var singleElement = queryable.ByLdapFilterAsync("(job=dirige*)", Queryable.Single);
var singleOrDefaultElement = queryable.ByLdapFilterAsync("(job=dirige*)", Queryable.SingleOrDefault);
var firstElement = queryable.ByLdapFilterAsync("(job=dirige*)", Queryable.First);
var firstOrDefaultElement = queryable.ByLdapFilterAsync("(job=dirige*)", Queryable.FirstOrDefault);
...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- Humanizer.Core (>= 2.14.1)
- Microsoft.CodeAnalysis.CSharp.Scripting (>= 4.6.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.