Template Specification vs Extension Method?

I am trying to understand the spec template, and I'm a little confused. I really could not find this useful for my specific requirements. I want to know what the problem is if I prefer extension methods to my complex spesifications? for instance

public static class ProductExtensions
{
    public static IQueryable<Product> InStocks(this IQueryable<Product> query)
    {
        return query.Where(p => p.InStock && !p.IsDeleted /*others goes here*/);
    }
}

I found it convenient to wrap my long specs with extension methods instead of using the spesification pattern. What is wrong with that?

+5
source share
3 answers

There is nothing wrong with your current approach.

, , , - , 5 .

, , , , - , .. InStock. "" , .

, , , .

+5

. , . , , IQueryable<Product> , , , , ? , API.

IQueryable , , , , IQueryable, .

+3

, , LINQ . (Where), .

, "", , LINQ, "". , IQueryable, IEnumerable. , LINQ to Entities, , .InStocks() SQL.

+3
source

All Articles