Skip to content

weareyou/Redhotminute.Plugin.Specification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redhotminute.Plugin.Specification

Nuget status

I have decided to discontinue developing this library. While trying to implement a sort mechanism I found the following library which does exactly what I need: https://www.nuget.org/packages?q=linqbuilder.

Package based on the Specifications pattern. I did not implement all methods since I haven't used them.

Get started

Install the Nuget package in your project(s).

Install-Package Redhotminute.Plugin.Specification

Create your first specication:

public class DangerousPoisonQuery : Specification<Poison>
{
    private readonly bool _isDangerous;

    public DangerousPoisonQuery(bool shouldBeDangerous)
    {
        _isDangerous = shouldBeDangerous;
    }

    public override Expression<Func<Poison, bool>> ToExpression() 
    => poison => poison.IsDangerous == _isDangerous;
}

Execute the query on a list:

var result = TestDataHelper.Samples
                           .AsQueryable()
                           .Where(query.ToExpression());

See the unit-test project for a full working example.

About

A simple plugin for using the Specification Pattern with Linq.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages