This is showing my lack of experience here: I am trying to do exactly that,
but don't know which tools or where the DTO's should live.
given this Ayende snipit:
public class OrderToOrderDTO
{
public delegate void Transformer(Order o, OrderDTO d);
List<Transformer> transforms = new List<Transformer>()
{
(y, z) => z.ID = y.Id,
(x,z) => z.CustomerName = x.Name
};
public OrderDTO Transform(Order k)
{
OrderDTO t = new OrderDTO();
transforms.ForEach((item) => item(k, t));
return t;
}
}
where should it "live"? (Like i said, i'm still trying to figure some things
out)
On Mon, Oct 19, 2009 at 9:38 AM, José F. Romaniello <
[email protected]> wrote:
> I don't know that, because I even don't know why do you need a DTO.
> DTO is the acronym of "Data Transfer Object", should be simple, you don't
> want to transfer something whit nhibernate inside.
> Try in your service; or if you will use NHibernate to fill the DTO, in your
> DAL.
>
> Sompeople use AutoMapper to Object-To-Object mapping. but.. It depends.
>
> 2009/10/19 YankeeImperialistDog <[email protected]>
>
>
>> What about this?
>> http://ayende.com/Blog/archive/2007/12/05/Object--Object-mapping.aspx
>>
>> On Oct 19, 8:57 am, YankeeImperialistDog <[email protected]>
>> wrote:
>> > Thanks for the reply,
>> > Your advise is appreciated and i'm going to agree with you. My
>> > question now is what stratagy would you recomend for DTO that
>> > minimizes coding and can make use of existing entities, but not break
>> > sepration? I'm really trying to organize, simplify, and standardize my
>> > projects even if it means creating a mini framework just for DTO, i'll
>> > do it.
>> >
>> > On Oct 17, 7:35 pm, José F. Romaniello <[email protected]> wrote:
>> >
>> >
>> >
>> > > It is not a good place for such logic.A dto should be simpler than
>> that.
>> > > Keep nhibernate in your DAL, repositories or dao.
>> >
>> > > 2009/10/17 YankeeImperialistDog <[email protected]>
>> >
>> > > > I'm creating, or trying to create a DTO for a Person class
>> > > > ******
>> > > > namespace KurtStack.Data.Repositories
>> > > > {
>> > > > public static class PersonDTO
>> > > > {
>> > > > public static object GetPersonDTO()
>> > > > {
>> > > > var session =
>> > > > IoC.Container.Resolve<INHibernateSessionProvider>() as ISession;
>> > > > var obj = session.CreateCriteria(typeof(Person))
>> > > > .CreateAlias("FirstName", "fn")
>> > > > .CreateAlias("LastName", "ln");
>> > > > return obj;
>> > > > }
>> > > > }
>> > > > }
>> > > > ***
>> > > > my problem is getting this to return to my UI via a Command object
>> > > > with out directly referencing INHibernateSessionProvider. Any ideas
>> on
>> > > > how to do this?
>> >
>> > > > my command object does not directly reference KurtStack.Data.
>> >
>> > > > so to get it to the UI i'd like to do something like this:
>> > > > GetPersonDTO. ... hrlp
>> >
>> > > > public class NewPersonCommand : ICommand
>> > > > {
>> > > > private readonly Person person;
>> >
>> > > > public static object GetPersonDTO()
>> > > > {
>> > > > object obj = GetpersonDTO();
>> > > > return obj;
>> > > > }- Hide quoted text -
>> >
>> > > - Show quoted text -- Hide quoted text -
>> >
>> > - Show quoted text -
>>
>>
>
> >
>
--
Kurt Schroeder
EverybodySafe, llc
847-800-7563
www.IKnowTek.com
www.EverybodySafe.com
Learning makes me feel alive.
Sharing what I learn gives my life meaning!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---