Use NHibernate AliasToBean Transformer launch n+1 query

后端 未结 1 1373
既然无缘
既然无缘 2020-12-22 02:30

Before edit my question I\'m sorry for my poor english.

I have two classes:

public class News
{
    public virtua int Id { get; set; }
    public vir         


        
相关标签:
1条回答
  • 2020-12-22 02:57

    In general there are two ways.

    1) we have to use Projections, and project all properties to be selected explicitly. Then we have to use some deeper transformation e.g. Deep transformer here

    2) we can use batch fetching, which will load all related relations in few batches. That will lead to 1 + 2(4) queries, to load all relations in separated (few) queries

    For more details about projections:

    • How to partially project a child object with many fields in nHibernate

    For more details about batch fetching you can check this:

    • documentation - http://nhibernate.info/doc/nh/en/index.html#performance-fetching-batch
    • How to Eager Load Associations without duplication in NHibernate? or
    • NHibernate: Select one to Many Left Join - Take X latest from Parent
    0 讨论(0)
提交回复
热议问题