Best approach for building NHibernate DTO's

后端 未结 4 1842
夕颜
夕颜 2021-01-03 03:16

I\'m new to NHibernate (and ORMS) and trying to come to grips with the myriad of different options it presents. For reference, I\'m using Fluent NHibernate with seperate bus

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-03 04:03

    Keep your loading/saving code separate from your DTOs. The DTO objects are only views of the underlying data.

    When doing your queries, return the DTOs by using a transformation. Something like this:

    resultSet = session.CreateCriteria(typeof(MyDataObject))
        .Add(query criteria, etc.)
        .SetResultTransformer(Transformers.AliasToBean())
        .List()

提交回复
热议问题