Re: Specification Pattern vs Data Mapper



Mikeon wrote:
MyObject[] GetMyObjectsBySpecification(ISpecification<T> spec);

From the model point of view, specification pattern is as clean and
nice as can be.
The question is: what to do with the specification when it comes to
data access layer code i.e. the data mapper.
How do you translate specification into a data access layer specific
code i.e. into SQL statemenents?

Hello Michal,

You should check out Eric Evans' book "Domain Driven Design":
http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215

Evans describes a way how to do selection with the specification pattern.
Unfortunately, I don't have the book here at the moment. So I can't give you more information about the suggestions from the book. If I remember correctly, Evans uses IoC to decouple the specifications and the SQL generation.

Ciao,
Jens

--
http://www.jenswinter.com
.