Questions tagged [specification-pattern]

Allows business rules to be recombined by chaining the business rules together using boolean logic. The pattern is frequently used in the context of domain-driven design.

114 questions
3
votes
2 answers

Specification Pattern for Querying against DataBase using NHibernate

How Do You Implement Specification Pattern for querying database using NHibernate?(without LINQ to NHibernate).I read a lot about Specification Pattern but most of them was about Validation and Querying Memory collection objects. Best method as far…
caltuntas
  • 10,747
  • 7
  • 34
  • 39
3
votes
1 answer

Linq: query syntax where operator does not understand predicates of type Expression

I have defined a specification as an object of type Expression> like this: public static Expression> IsSystemUser { get { return user => user.UserID == -1; } } This works marvellously with queries written…
David
  • 15,750
  • 22
  • 90
  • 150
3
votes
0 answers

Specification pattern vs Always valid domain model

Let's say we have two aggregates: public class Order : IAggregateRoot { public Address Address { get; private set; } public int? BuyerId {get; private set} public OrderStatus OrderStatus { get; private set; } public string…
3
votes
2 answers

How to create a collection of Expression>?

I have a repository with the following method: IEnumerable FindAll(Specification specification, Expression> fetchExpression); I need to pass in more than one expression. I was…
3
votes
2 answers

Implementing a Factory that uses Specifications to determine which type of object to create

This is mainly a thought experiment. So this all is sample code. My goal was to use the specification pattern to eliminate giant blocks of conditional code inside a factory. So with this sample I have a StatusData object that I want to get an…
NotMyself
  • 29,209
  • 17
  • 56
  • 74
3
votes
2 answers

Specification Pattern using SQL without an ORM, with the repository pattern

I have been looking into the specification pattern that is briefly described in martin fowler's patterns of enterprise architecture under the repository pattern section, as well as several examples on the web. However, almost all of the…
gmn
  • 4,199
  • 4
  • 24
  • 46
3
votes
0 answers

Query Cache does not work with Specification?

My project is Spring-boot + Spring-data-jpa + hibernate + ehcache. The 2nd level cache works with the followings: extends JpaRepository 2a. it works with my HQL query with query.setHimt("org.hibernate.cacheable", true); It does not work if I wrap…
3
votes
1 answer

Need Func to supply to Where() method of both IEnumerable and IQueryable

I have a Func defined as follows: Func IsSuperhero = x => x.WearsUnderpantsOutsideTrousers; I can query IEnumerables like this: IEnumerable foos = GetAllMyFoos(); var superFoos = foos.Where(IsSuperhero); But when I try to supply…
David
  • 15,750
  • 22
  • 90
  • 150
3
votes
1 answer

git ignore specific directories

I wanted to recently upload my dotnetnuke website on git, now my website has gigs of images which i don't want to upload over git.I was searching on GIT and came across .gitignore file which gets created during repository creation, GIT has a…
Abbas
  • 4,948
  • 31
  • 95
  • 161
3
votes
2 answers

Delete columns in text files with specific string

I would like to delete collumns with a specific string "Gtype." from a .txt tab delimited file. I already have tried this command in R: df <- df[, -grep("GType.", colnames(df))] to do this task. However my matrix is too big (more than 13 GB), and R…
user3091668
  • 2,230
  • 6
  • 25
  • 42
2
votes
1 answer

Ardalis.Specification and Azure Cosmos Database : What is the place where the query is applied? Cosmos Database or Application Memory?

I am trying to implement Ardalis.Specification in .net core Web API application that uses Azure Cosmos Database Below is my Specification definition public class ToDoItemSearchSpecification : Specification { public…
One Developer
  • 99
  • 5
  • 43
  • 103
2
votes
1 answer

Proper aggregate design and complex specification query

I have a lack of understanding of the DDD aggregate topic. I do have an Offer aggregate that has navigation property to its children's collection OfferProducts. When I learned entity framework I thought I should always define navigation properties…
2
votes
1 answer

Does The Unit Of Work Make Sense with Clean Architecture(DDD) Or Just The Repository Is Enough?

I want to ask if it make sense to use the unit of work with repositories on a project following the domain driven design philosophy and clean architecture or it doesn't make more sense and the generic repository pattern is sufficient?
2
votes
2 answers

Entity Framework - Opinion on need of Business layer

At the moment my website has a repository pattern with the specification pattern in it. I can get data from within my .aspx page with just a few lines of code, example: private IRepository repository; protected void Page_Load(object sender,…
Julian
  • 1,105
  • 2
  • 26
  • 57
2
votes
2 answers

DDD pass filters through multiple layers

In my onion architecture I've my PresentationLayer who contains a class named LogRabbitMQFilters with differents properties to filter search. I pass LogRabbitMQFilters in ApplicationLayer by mapper : public RabbitMQController(IELKService…