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