Linq.Extension.PredicateBuilder 1.0.0

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

// Install Linq.Extension.PredicateBuilder as a Cake Tool
#tool nuget:?package=Linq.Extension.PredicateBuilder&version=1.0.0                

Linq.Extension.PredicateBuilder

A library that build dynamic query predicate with filters in Linq.

Installation

Install Linq.Extension.PredicateBuilder with Nuget

  dotnet add package Linq.Extension.PredicateBuilder

Usage

internal class Program
{
    static void Main(string[] args)
    {
        var searchFilters = new List<SearchFilter> {
            new SearchFilter{PropertyName = "Name", Operation = OperatorComparer.BeginsWith, Value = "post" },
            new SearchFilter{PropertyName = "IsPublished", Operation = OperatorComparer.Equal, Value = true },
            new SearchFilter{PropertyName = "TotalViews", Operation = OperatorComparer.GreaterOrEqual, Value = 150 },
        };

        var predicate = PredicateBuilder.Compile<Post>(searchFilters);

        var filteredPostsResult = new Post().GetPosts().Where(predicate).ToList();
    }
}

public class Post
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public bool IsPublished { get; set; }
    public DateTime PublishedAt { get; set; }
    public int TotalViews { get; set; }
    public int TotalComments { get; set; }

    public List<Post> GetPosts()
    {
        var posts = new List<Post>
        {
                new Post {Id = 1, Name = "post1" , Description = "post1 description", IsPublished = true, PublishedAt = DateTime.Now, TotalViews = 50, TotalComments = 4},
                new Post {Id = 2, Name = "post2" , Description = "post2 description", IsPublished = false, PublishedAt = DateTime.Now.AddDays(-3), TotalViews = 10, TotalComments = 1},
                new Post {Id = 3, Name = "post3" , Description = "post3 description", IsPublished = true, PublishedAt = DateTime.Now.AddDays(-8), TotalViews = 120, TotalComments = 8},
                new Post {Id = 4, Name = "post4" , Description = "post4 description", IsPublished = true, PublishedAt = DateTime.Now.AddDays(-1), TotalViews = 40, TotalComments = 5},
                new Post {Id = 5, Name = "post5" , Description = "post5 description", IsPublished = true, PublishedAt = DateTime.Now, TotalViews = 0, TotalComments = 0},
                new Post {Id = 6, Name = "post6" , Description = "post6 description", IsPublished = true, PublishedAt = DateTime.Now.AddDays(-10), TotalViews = 150, TotalComments = 10},
                new Post {Id = 7, Name = "post7" , Description = "post7 description", IsPublished = false, PublishedAt = DateTime.Now, TotalViews = 0, TotalComments = 0},
                new Post {Id = 8, Name = "post8" , Description = "post8 description", IsPublished = true, PublishedAt = DateTime.Now.AddDays(-20), TotalViews = 250, TotalComments = 15},

        };
        return posts;
    }
}
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.
  • net6.0

    • No dependencies.

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
2.2.0 249 7/18/2023
2.1.0 172 7/18/2023
2.0.0 180 7/17/2023
1.1.0 149 6/8/2023
1.0.0 168 5/25/2023