NHibernate AliasToBean transformer associations

There is my master piece… which I’m using to transform any level of projections depth. Take it and use it like this: .SetResultTransformer(new DeepTransformer<MyEntity>()) It could be used for any ValueType properties, many-to-one references and also for dynamic objects… public class DeepTransformer<TEntity> : IResultTransformer where TEntity : class { // rows iterator public object TransformTuple(object[] … Read more

Query on HasMany reference

As almost always, NHibernate does have answer for this. What we are here trying to achieve would be a SQL Statement lookin like this: // final Request selection SELECT request.[RequestId] FROM [Request] request // Only requests, which are successful, and have Max(date) WHERE request.[RequestId] IN ( SELECT successResponse.RequestId as y0_ FROM [Response] successResponse // response … Read more

How to Eager Load Associations without duplication in NHibernate?

Fetching Collections is a difficult operation. It has many side effects (as you realized, when there are fetched more collections). But even with fetching one collection, we are loading many duplicated rows. In general, for collections loading, I would suggest to use the batch processing. This will execute more SQL queries… but not so much, … Read more