On May 13, 11:25 pm, Fabio Maulo <[email protected]> wrote:
>
> I understand so and so....NH work with entities and not with fields. What
> you are looking for is something more like to what you can do with pure
> ADO.NET and pure SQL.
> From the view you can receive a DTO but to update an entity you need and
> entity and not part of it.
>

Fabio, I understand what you are saying, and I think it makes complete
sense when we are talking about POCO mode with OO semantics. I want to
challenge you a little bit, though, to think about what the words
"entity" and "DTO" mean when we are dealing with dynamic-map mode.

Being in dynamic-map mode is similar to having an "anemic domain": no
behavior, just data containers. Indeed, dynamic-map mode takes the
"anemic domain" to the next level because all of our entities are of
the same type, IDictionary.

So what is a DTO in this dynamic-map world? In the POCO world a DTO is
an anemic abbreviated *different* type. In the dynamic-map world, a
DTO is an anemic abbreviated *same* type: again, both the entity and
the DTO are IDictionary. In the dynamic-map world, a DTO is simply an
entity with some missing keys.

Coming at it from a different direction, we agree that having NH
define entity/DTO merge semantics in POCO node would not make any
sense. Merging an instance of CustomerDTO with an instance of Customer
is not something that NH should know how to do. But merge semantics in
dynamic-map mode are clear and simple so long as your abbreviated
"DTO" IDictionary instance is simply a subset of your full-blown
"entity" IDictionary instance. This is easy to demonstrate:

persistedEntity["Id"] = 1
persistedEntity["Name"] = "widget1"
persistedEntity["Description"] = "foo"
persistedEntity["ParentId"] = 9
persistedEntity["Inserted"] = "2005/05/05"
persistedEntity["DeleteFlag"] = 0

editedEntity["Id"] = 1
editedEntity["Description"] = "bar"
editedEntity["ParentId"] = NULL

mergedEntity = session.Merge("Widget", editedEntity)


The proof is that I don't need to tell you what mergedEntity looks
like. You already know. :)

And the code to achieve this is fairly trivial, as you can imagine.
I'm about to write it for my project. I keep talking about this
because I think it feels like a missing feature in NH's dynamic-map
mode. Please give it some thought and let me know what you think?


Thanks,

--Stuart


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to