nhibernatedtonhibernate-projections

How to save DTO with NHibernate?


What I would like to do:

  1. Get DTO using projections
  2. In UI I edit this DTO object
  3. Save modified object

How can I save DTO object? Should I requery domain and merge it dto? Is there a possibility to specify projections for saving?


Solution

  • Should I requery domain and merge it dto? 
    

    Yes. That is pretty much what you'll need to do. NHibernate won't know what to do with your DTO, so none of the session methods to persist objects will work with your DTO.

    Is there a possibility to specify projections for saving?
    

    No. The only "projections for saving" are in ur NH mapping for the entity.