开发者

Why does .Fetch() throws an null reference exception?

I have the following nhibernate linq query and it throws a null reference exception

promotions = (from a in session.Query<Application>()
                          from ap in a.Promotions
                          where a.Id == applicationId
                          && ap.EndDate >= DateTime.Now && ap.StartDa开发者_JS百科te <= DateTime.Now
                          select ap).Fetch(ap => ap.LandingPage).ToList();

The same query without the .Fetch() works fine. I am passing the same id both times, so it's not a data issue.

Is this a bug, or by design? How can I make it not throw an exception?


If you move the .Fetch(ap => ap.LandingPage) to immediately after the declaration does that change the outcome?

from ap in a.Promotions.Fetch(ap => ap.LandingPage)


from a in session.Query<Application>().Fetch(ap => ap.LandingPage)
//the rest of your code
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜