Masoud Sedghi
Masoud Sedghi

Reputation: 614

a collection of ValueObjects as result of a database query

Given tha nature of ValueObjects in DDD,it can be considered a collection of them as a container that contains the result set of a database query?

for example,this pseudocode could be a reasonable usage of ValueObject concept?:

List<ValueObject> resultSet = GetValueObjectsFromDB();

List<ValueObject> GetValueObjectsFromDB()
{
    return ExecuteCommand("SELECT * FROM dbo.AnEntity");
}

Upvotes: 0

Views: 102

Answers (1)

Tomasz Jaskuλa
Tomasz Jaskuλa

Reputation: 16013

I think you confuse Value Object which is one of the building blocks of Domain Driven Design and DTO (Data Transfert Object) which is a dumb data container.

Value Object : An object has no conceptual identity. They should be treated as immutable. Value Object plays his role in a domain model and very often have a behaviour associated with it.

DTO : It's just a dumb data container that can be used for transfering data on the wire or between architectural layers.

What you would use on the 'query' side is a DTOs tailored to your specific needs. If you want to display it on the screen or transfert this data to another system the DTOs is the way to do it.

Upvotes: 1

Related Questions