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.
Questions tagged [specification-pattern]
114 questions
2
votes
2 answers
Domain driven design - How to check uniqueness of one property in domain object
I'm developing an application using domain driven design. One of the patterns I've been using is Repository pattern. For the sake of simplicity, let's say I have following classes and interfaces.
Car - domain class representing car domain…

Milivoj Milani
- 315
- 2
- 11
2
votes
2 answers
DDD specification pattern with stored procedure
I am going to write a stored procedure which will pull back X number of records based on a query. This SP may need to lock the records while it does the search. I am also using EF which I know can't use pessimistic locking.
Instead of having the…

user1180223
- 111
- 8
1
vote
0 answers
How to filter entity's @OneToMany relationships with JPA Criteria API?
I have a Parent entity with 5 relationships. I am using a findAll(Specification spec) in my JpaRepository to filter the Parent by 3 of its relationships.
The last two relationships are unidirectional @OneToManys, List name and…

rbrewster
- 61
- 6
1
vote
0 answers
What is the most efficient way to filter a Pojo's OneToMany field retrieved in a JpaSpecification findAll?
I am using the JpaSpecification to get a list of filtered ProfileEntity. ProfileEntity has a @OneToMany List channels field. Each of the ProfileEntitys will have 5 Channels associated with it but I want my…

rbrewster
- 61
- 6
1
vote
0 answers
Spring Data Join Query using Specification in unrelated tables
Have 2 entities
@Table(name = "REQUEST")
public class RequestEntity {
@Id
@Column(name = "REQUEST_ID")
private String requestId;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "REQUEST_ID")
…

javajive
- 11
- 2
1
vote
2 answers
How to implement specification pattern in Rust?
I'm wondering what is the idiomatic way to create a specification pattern in Rust?
Let's say there is a WorkingDay struct and two specifications should be created
IsActiveWorkingDaySpecification
IsInFutureWorkingDaySpecifictaion
My current…

Roman Mahotskyi
- 4,576
- 5
- 35
- 68
1
vote
1 answer
Is there a way to combine Specification classes in the Ardalis.Specification library?
I am new to the Ardalis.Specification library and to the Clean Architecture in general. I was wondering if there might be a way to group multiple specification classes to make a composable query. It would be helpful for complex queries involving a…

Arkena
- 23
- 1
- 7
1
vote
1 answer
Difficulty joining collections using a repository pattern with EF4
I'm having trouble getting the design behind this correct. I'm using a repository pattern to manage my datalayer. In one of my controllers (MVC3) i am constructing a LINQ query that needs to perform a join. I have 2 questions about this:
Is is…

Syg
- 403
- 4
- 17
1
vote
1 answer
LINQ expressions can not be translated to Sql when combining specifications in Specification Pattern
I am using the Specification pattern to perform db filtering, and avoid doing it on memory (I roughly followed this article). My base specification class is something like this:
public abstract class Specification : ISpecification{
…

gst
- 31
- 3
1
vote
3 answers
dplyr Find records that have specifc set of values
I have a dataset that has some ID and associated timepoints. I want to filter out IDs that have a specific combination of timepoints. If I filter using %in% or |, I get IDs out of the specific combination. How do I do this in R…

Datamaniac
- 171
- 2
- 9
1
vote
1 answer
Dynamic Expression API: I can do a predicate, how to code an OrderBy Specification?
I figured out how to do a predicate from a string supplied by a client based on Dynamic Linq (this is wrapped in a Specification object):
return System.Linq.Dynamic.DynamicExpression.ParseLambda
(filter.ToString(),…

Zachary Scott
- 20,968
- 35
- 123
- 205
1
vote
2 answers
Criteria Query to retrieve data from DB using specification and predicate
I have two tables (user, vehicles) and i want to write criteria query to retrieve data from db using criteria query specification and predicate to both Join Tables.
select ur.id, count (ur.vehicle_FK) from user so
inner join VEHICLE vhe on…

Sam
- 165
- 10
1
vote
2 answers
How to add a .ThenInclude for a nested object within a generic specification pattern in C#
I've implemented a generic spec pattern for my generic repo, but I don't know how I can add a .ThenInclude() to the code.
FYI - I have 3 entities (User->PracticedStyles->YogaStyles) and when I go to fetch my User I want to fetch all the YogaStyles…

chuckd
- 13,460
- 29
- 152
- 331
1
vote
1 answer
Reusable expression
Given a query with a Where clause
CollectionA.Where(a => a.Prop1 == val1 && a.Prop2 == val2)
and another query with a similar Where clause but the properties are linked via the Reference.
CollectionB.Where(b => b.Reference.Prop1 == val1 &&…

Wouter
- 2,540
- 19
- 31
1
vote
0 answers
Onion Architecture database mappings
I have been playing with Onion Architecture, DDD and Specification pattern. There are many implementations with Entity Framework, where domain entities going right in the DBSet<> of the context. For me, it's not ok, at least because of many-to-many…

Balianytsia Artem
- 19
- 1
- 4