Linq.Extension.PredicateBuilder 2.2.0

dotnet add package Linq.Extension.PredicateBuilder --version 2.2.0
NuGet\Install-Package Linq.Extension.PredicateBuilder -Version 2.2.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="2.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Linq.Extension.PredicateBuilder --version 2.2.0
#r "nuget: Linq.Extension.PredicateBuilder, 2.2.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=2.2.0

// Install Linq.Extension.PredicateBuilder as a Cake Tool
#tool nuget:?package=Linq.Extension.PredicateBuilder&version=2.2.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 predicate = new PostViewComponentModel
            {
                Search = new List<Search>
                {
                    new Search
                    {
                        Field = new Field{ Value = "PublishedAt" },
                        Operator = new Operator { Value = OperatorComparer.Between},
                        Value = new Value{ value =  "07/08/2023" , value2 = "07/18/2023"}
                    },
                    new Search
                    {
                        Field = new Field{ Value = "Name" },
                        Operator = new Operator { Value = OperatorComparer.BeginsWith },
                        Value = new Value{ value = "p" }
                    },
                    new Search
                    {
                        Field = new Field{ Value = "Status" },
                        Operator = new Operator { Value = OperatorComparer.In },
                        Value = new Value{ value = "0,2" }
                    }
                },
                PageNumber = 1,
                PageSize = 20
                
            }; 
            var result = new Post().GetPosts().BuildQuery(predicate.PredicateBuilderFilterRule
                , new PredicateBuilderOptions() { CultureInfo = CultureInfo.CurrentCulture }).ToPaged(predicate);
        }
    }

    public enum Status
    {
        New,
        Pending,
        Completed
    }


    public class PostViewComponentModel : PredicateBuilderInvokerBase<Post>
    {
    }

    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 Status Status { get; set; }

        public IQueryable<Post> GetPosts()
        {
            var posts = new List<Post>
            {
                new Post {Id = 1, Name = "POST1" , Description = "post1 description", IsPublished = true, 
                    PublishedAt = DateTime.Now.AddMinutes(-3), TotalViews = 50, TotalComments = 4 , Status = 0},

                new Post {Id = 2, Name = "POST2" , Description = "post2 description", IsPublished = false,
                    PublishedAt = DateTime.Now.AddDays(-1), TotalViews = 10, TotalComments = 1 , Status = (Status)1},

                new Post {Id = 3, Name = "POST3" , Description = "post3 description", IsPublished = true,
                    PublishedAt = DateTime.Now.AddDays(-8), TotalViews = 120, TotalComments = 8, Status = (Status)2},

                new Post {Id = 4, Name = "POST4" , Description = "post4 description", IsPublished = true,
                    PublishedAt = DateTime.Now.AddDays(-1), TotalViews = 40, TotalComments = 5, Status = (Status)1},

                new Post {Id = 5, Name = "POST5" , Description = "post5 description", IsPublished = true,
                    PublishedAt = DateTime.Now, TotalViews = 0, TotalComments = 0 , Status = (Status)2},

                new Post {Id = 6, Name = "POST6" , Description = "post6 description", IsPublished = true,
                    PublishedAt = DateTime.Now.AddDays(-10), TotalViews = 150, TotalComments = 10, Status = (Status)2},

                new Post {Id = 7, Name = "POST7" , Description = "post7 description", IsPublished = false,
                    PublishedAt = DateTime.Now, TotalViews = 0, TotalComments = 0, Status = (Status)2},

                new Post {Id = 8, Name = "POST8" , Description = "post8 description", IsPublished = true,
                    PublishedAt = DateTime.Now.AddDays(-20), TotalViews = 250, TotalComments = 15, Status = 0},

            };

            return posts.AsQueryable();
        }
    }
   
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
2.2.0 192 7/18/2023
2.1.0 141 7/18/2023
2.0.0 150 7/17/2023
1.1.0 121 6/8/2023
1.0.0 138 5/25/2023