- Motivation
- An object that represents a database query and can automatically generate queries on the fly based on context supplied.
- Summary
- A Query Object is an interpreter, that is, a structure of objects that can form itself into a SQL query. You can create this query by referring object context like classes and fields rather than tables and columns.
- This makes queries independent of the database schema and changes to the schema can be localized in a single place.
- it is usually uses Metadata Mapping pattern to generate actual database queries.
- When to Use
- Query Objects are a pretty sophisticated pattern
to put together, so most projects don't use them if they have a handbuilt data
source layer.
- ORM Frameworks like EF provide this feature out of the box and must be preferred over handcrafting
- References
- http://martinfowler.com/eaaCatalog/queryObject.html
|
|