开发者

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

开发者 https://www.devze.com 2023-03-17 05:20 出处:网络
I have the following nhibernate linq query and it throws a null reference exception promotions = (from a in session.Query<Application>()

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

精彩评论

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

关注公众号