为什么 .Fetch() 会抛出空引用异常?
我有以下 nhibernate linq 查询,它抛出空引用异常
promotions = (from a in session.Query<Application>()
from ap in a.Promotions
where a.Id == applicationId
&& ap.EndDate >= DateTime.Now && ap.StartDate <= DateTime.Now
select ap).Fetch(ap => ap.LandingPage).ToList();
没有 .Fetch() 的相同查询工作正常。我两次都传递相同的 id,所以这不是数据问题。
这是一个错误,还是设计使然?我怎样才能让它不抛出异常?
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.StartDate <= 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果将 .Fetch(ap => ap.LandingPage) 移至声明之后,会改变结果吗?
If you move the .Fetch(ap => ap.LandingPage) to immediately after the declaration does that change the outcome?