What does really POCO mean, in respect to dependencies?
With NHibernate; child collections are retrieved as NHibernate.Collection.Generic.PersistentGenericBag<>. This is what I here mean by “dependencies”; If I try to save/update an object graph, the DAL will already have it’s “opinion” about what & how I’m trying to persist it.
Initially, I thought that requesting a POCO would carry no depencencies to the DAL, repository, ORM (unsure what is correct term in this perspective). But now I’m confused, as I’m thinking maybe it just means that the POCO class has no persistence methods; And that retrieving a POCO object graph may still carry such dependencies?
So when you talk about POCO, what do you really mean? Can a POCO have these type of dependencies, and if it may AND may not, how do you “by name” distinguish those?
A POCO that “has no such dependencies” seems more like a DTO, in some respect, but can have behavior, so it’s not a DTO after all.
Also, just to be 100% sure: I assume a DTO would be persistent ignorant AND have “no dependencies” ?
Maybe “dependencies” is not the proper word to use, so in case correct me. I hope my question is still comprehensible.
EDIT1:
With some further thinking; Maybe my assumption that the …PersistentGenericBag brought with it some “dependencies” is wrong (?) Probably it’s just a type, and nothing more magical. And further; that the only dependencies the objects have to NH, are via the ISessions, which of course, we have control over. Does that make sense?
POCO are classes that does not have any dependencies on frameworks or any other infrastructure class. Well, NHibernate DOES use the
PersistentGenericBagbut your POCO will only reference anIListclass.For your POCO, it does’t matter if this instance will be a
List, aReadOnlyListor aPersistentGenericBag, he will treat it as anIListbut will have other behaviour that is not up to him deal with.By the way, if you’re mapping your Domain Objets with annotations you know have a clearly dependency to the ORM.