开发者

How to apply DistinctRootEntityResultTransformer to all queries in NHibernate

When executing queries with eager loading some one-to-many associations i'm always using DistinctRootEntityResultTransformer (to not to have duplicated Video entries in a result list) like:

var video = session.QueryOver&l开发者_如何学编程t;Video>().Where(x => x.Id == 146)
                    .Fetch(x => x.Genres).Eager
                    .TransformUsing(new DistinctRootEntityResultTransformer())
                    .List();

Is there a way to apply this globally to all the queries, at the ISessionFactory configuration time? Cause in most cases I certainly want it to be enabled.


No, it's not possible.

You could do that in a base repository class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜