Often I see POCO classes containing IDs of the corresponding records in the Database. To me this is sort of a violation of the persistence ignorance idea.
I thought the idea of POCO is that there is no notion of persistence whatsoever. E.g. a car object has tires, a wheel and can be started and stopped, but how it is created or retrieved is totally irrelevant.
An ID is usually only there for being able to interact with the database. Therefore my conclusion would be that an object need not know its ID as long as it is uniquely definable by its other fields (such as a name).
Apart from that I often see methods for converting to and from DTO also in the POCO objects, am I right into thinking this is not proper POCO style either? Where would be the best place to put this conversion logic?
So bottom line, 3 questions:
- Why do POCO objects contain record IDs?
- Why do POCO objects contain conversion to and from DTO?
- What would be the best place in the architecture/design for conversion to and from DTO?
LonesomeProg...
None
0 Points
4 Posts
POCO including IDs of entities and methods for conversion to and from DTO
Oct 04, 2011 02:56 PM|LINK
Often I see POCO classes containing IDs of the corresponding records in the Database. To me this is sort of a violation of the persistence ignorance idea.
I thought the idea of POCO is that there is no notion of persistence whatsoever. E.g. a car object has tires, a wheel and can be started and stopped, but how it is created or retrieved is totally irrelevant.
An ID is usually only there for being able to interact with the database. Therefore my conclusion would be that an object need not know its ID as long as it is uniquely definable by its other fields (such as a name).
Apart from that I often see methods for converting to and from DTO also in the POCO objects, am I right into thinking this is not proper POCO style either? Where would be the best place to put this conversion logic?
So bottom line, 3 questions:
- Why do POCO objects contain record IDs?
- Why do POCO objects contain conversion to and from DTO?
- What would be the best place in the architecture/design for conversion to and from DTO?