Not used it, but AutoMapper may ease the pain of translating from
domain model to DTO:
http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/01/22/automapper-the-object-object-mapper.aspx



On Aug 11, 11:42 am, Krzysztof Koźmic (2) <[email protected]> wrote:
> inline
>
> On Aug 11, 12:30 pm, RhysC <[email protected]> wrote:> I have to ask 
> "why?"
>
> Because I want to put ClientData on the wire via WCF, and Order, is a
> big entity, with cyclic references, which WCF does not handle well,
> and I simply don't need all of it. So I want to send ClientData with
> pieces of Order in flatened form of OrderDto.
>
> > any way if you explictly want the dto as a separet object with an id
> > the why not have a seperate type that has an id an component
> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="xxx"
> > assembly="xxx" >
> > <class name="OrderThing" table="OrderThing">
> >     <id name="Id" column="Id" >
> >       <generator class="assigned" /><!-- ??? -->
> >     </id>
> >     <component class="OrderDTO" name="OrderDTO">
> >       <property ..... />
> >     </component>
> >   </class>
> > </hibernate-mapping>
>
> I'm not sure I understand. I don't want OrderDTO to have its own key.
>
> Let me express that in code:
>
> ClientData client = ...;//Get other properties
> ICollection<Order> clientOrders = GetOrdersForClient(client);
> IDictionary<Guid,OrderDto> orderDtos = client.Orders;
> foreach(var order in clientOrders)
> {
> orderDtos.Add(order.Id, MapToDto(order)); //it's keyed by Order.Id
>
> }
>
> I just want NHibernate to do that for me.
> I want to have (in DB) one to many from ClientData table to Order
> table.
> and in the object model one to many from ClientData object to OrderDto
> object, and have NHibernate map that on the fly.
> something like, in HQL you can do "select new OrderDto(o.Name, ...)
> from Order o".
>
>
>
>
>
> > is that going to help? it doe mean there is an object that is in
> > effect acting like a dictionary (orderThing) but you get access to
> > your dto with out an ID
>
> > is this even close to what you are after?
>
> > RhysC
> > On Aug 11, 5:07 pm, Krzysztof Koźmic (2) <[email protected]> wrote:
>
> > > I have two types in my domain, say ClientData and Order
> > > Client can have multiple orders so its 1-n relation.
>
> > > However, I want ClientData class, to not have Orders collection
> > > ICollection<Order> but instead to have IDictionary<Guid,OrderDTO> that
> > > is dictionary of DTOs for Order, keyed by order Id.
>
> > > How do I construct my mapping for that, so that I'll be able to do
> > > simply session.CreateCriteria<ClientData>().List<ClientData>(); and
> > > get all I need?
>
> > > thanks in advance.
>
> > > Krzysztof
--~--~---------~--~----~------------~-------~--~----~
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