1

我面临着select N+1 issue以下查询。我是新手NHibernate。谁能帮我解决这个查询NHibernate using Eager loading

public IList<MasterForecastInputSourceMatch> GetMasterForecastInputSourceMatchInfo(Guid elementId)
{
        var selectQuery = _session.CreateQuery("from MasterForecastInputSourceMatch where ElementInputInfo.Id = :id")
            .SetParameter("id", elementId);
        return selectQuery.List<MasterForecastInputSourceMatch>();
}

这是生成的查询。我使用 NHibernate Profiler

select masterfore0_.Id                    as Id88_,
   masterfore0_.UpdateDate            as UpdateDate88_,
   masterfore0_.MasterForecastInfo_id as MasterFo3_88_,
   masterfore0_.ElementInputInfo_id   as ElementI4_88_
   from   [PATH_MasterForecastInputSourceMatch] masterfore0_
   where  masterfore0_.ElementInputInfo_id = 'c414e888-cb9b-4c11-a52d-9fcd00a05ba4'
4

0 回答 0