表达式不能包含lambda表达式 [英] Expression cannot contain lambda expressions

查看:151
本文介绍了表达式不能包含lambda表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经如下( .Include())获取了 List<> p>

I have fetched the List<> object as below (with .Include()):

List<vDetail> entityvDetails =
    context.vDetails
    .Include("payInstallment.appsDetail")
    .Include("payInstallment.appsDetail.application")
    .Include("payInstallment.appsDetail.purposes")
    .Where(e => e.vch_id == 123).ToList();

然后在代码中的某个地方我尝试过滤实体记录如下:

And then somewhere in the code ahead I tried to filter the entity record as below:

foreach (vDetail item in lstVDetails)
{
    ... 

    int purposeId = entityvDetails.Where(e => e.sad_id == item.sad_id).FirstOrDefault().payInstallment.appsDetail.purposes.prp_id;

    ...
}

代码编译完美。但是,运行时返回以下错误(尽管包括所有导航):

Code compiling perfect. However, the runtime returning following error (although all navigations are included):

Object reference not set to an instance of an object.

所以我设置使用监视窗口进行调试。现在在观察窗口分析下面的语句:

So I set for debugging using the watch window. Now while analyzing the below statement in watch window:

entityVoucherDetails.Where(e => e.sad_id == item.sad_id).FirstOrDefault()

生成以下错误的观察窗口:

the watch window generated following error:


表达式不能包含lambda表达式。

Expression cannot contain lambda expressions.

请是否有人可以告诉我什么可以作为原因?

Please if anybody can tell me what could be the reason?

推荐答案

不支持评估调试器(watch window)中的Lambda表达式。

Evaluating Lambda expressions in debugger (watch window) is not supported yet.

打开功能请求

为了调试问题,您应该将lambda表达式的结果分配给专用变量,并将其用于以下语句。 p>

For debugging your problem you should assign the result of the lambda expression to a dedicated variable and use that in following statements.

var entity = entityvDetails.Where(e => e.sad_id == item.sad_id).FirstOrDefault();






更新08/2014: strong>
Microsoft发布了功能要求的更新,宣布他们开始工作:


Update 08/2014: Microsoft posted an update on the feature request announcing that they started to work on it:


所以这里是我们站在哪里。

So here’s where we stand.


  • 1)我们希望这可以像您一样工作。没有审查 - 它正在进行中。

  • 2)我们知道如何使其工作;

  • 3)我们正在重写所有内容。

  • 4)重写一切都需要很多的时间和很多测试。

  • 1) We want this to work as much as you do. It’s not under review – it’s in progress.
  • 2) We figured out how to make it work; it simply requires rewriting everything.
  • 3) We’re rewriting everything.
  • 4) Rewriting everything takes a lot of time and a lot of testing.






更新11/2014:
Microsoft终于在VS2015中实现了一些限制。 阅读这里

这篇关于表达式不能包含lambda表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆