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?
There is nothing wrong with your current approach.
, , , - , 5 .
, , , , - , .. InStock. "" , .
InStock
, , , .
. , . , , IQueryable<Product> , , , , ? , API.
IQueryable<Product>
IQueryable , , , , IQueryable, .
, , LINQ . (Where), .
Where
, "", , LINQ, "". , IQueryable, IEnumerable. , LINQ to Entities, , .InStocks() SQL.
IQueryable
IEnumerable
.InStocks()