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

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

问题描述

我已经获取了 List<> 对象如下(使用 .Include()):

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?

推荐答案

尚不支持在调试器(观察窗口)中评估 Lambda 表达式.

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

有一个开放的功能请求 因为它.

Theres an open feature request for it.

为了调试您的问题,您应该将 lambda 表达式的结果分配给一个专用变量,并在以下语句中使用它.

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();

<小时>

2014 年 8 月更新:微软发布了关于功能请求的更新,宣布他们开始着手处理它:


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

这就是我们的立场.

  • 1) 我们希望它像您一样工作.未在审核中 - 正在进行中.
  • 2) 我们想出了如何让它发挥作用;它只需要重写一切.
  • 3) 我们正在重写一切.
  • 4) 重写所有内容需要大量时间和大量测试.

<小时>

11/2014 更新:微软最终在 VS2015 中实现了它,但有一些限制.阅读此处.


Update 11/2014: Microsoft finally implemented it with some limitations in VS2015. Read here.

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

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