AxaFrance.LdapFiltersToLambdaExpression 1.0.1

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package AxaFrance.LdapFiltersToLambdaExpression --version 1.0.1                
NuGet\Install-Package AxaFrance.LdapFiltersToLambdaExpression -Version 1.0.1                
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="AxaFrance.LdapFiltersToLambdaExpression" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AxaFrance.LdapFiltersToLambdaExpression --version 1.0.1                
#r "nuget: AxaFrance.LdapFiltersToLambdaExpression, 1.0.1"                
#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 AxaFrance.LdapFiltersToLambdaExpression as a Cake Addin
#addin nuget:?package=AxaFrance.LdapFiltersToLambdaExpression&version=1.0.1

// Install AxaFrance.LdapFiltersToLambdaExpression as a Cake Tool
#tool nuget:?package=AxaFrance.LdapFiltersToLambdaExpression&version=1.0.1                

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 178 6/22/2023
1.0.2 147 6/22/2023
1.0.1 149 6/20/2023
1.0.0 171 6/20/2023