如何急切加载查询

时间:2013-05-22 13:58:39

标签: c# sql-server-2008 fluent-nhibernate

我正面临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'

0 个答案:

没有答案
相关问题