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

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

问题描述

我已经取了列表与LT;> 对象,如下(以 .INCLUDE()

 列表< vDetail> entityvDetails = 
context.vDetails
.INCLUDE(payInstallment.appsDetail)
.INCLUDE(payInstallment.appsDetail.application)
.INCLUDE(payInstallment.appsDetail.purposes )
。凡(E => e.vch_id == 123).ToList();



然后在未来的代码的某个地方我试图筛选如下实体记录:



 的foreach(在lstVDetails vDetail项)
{
...

INT purposeId = entityvDetails.Where(E => e.sad_id == item.sad_id).FirstOrDefault()payInstallment.appsDetail.purposes.prp_id。


}

代码编译完美。然而,运行时返回下列错误(尽管所有的导航都包括在内):

 对象引用未设置到对象的实例。 



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

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

监视窗口中生成以下错误:

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

请,如果有人能告诉我可能是什么原因?


< DIV CLASS =h2_lin>解决方案

在调试器(监视窗口)评估Lambda表达式还没有被支持。



即使世界开放的<一个HREF =htt​​ps://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2049821-debug-lambda-expressions>它的功能要求。



有关调试的问题,您应该lambda表达式的结果分配给一个专门的变量和使用,在下面的语句。

  VAR实体= entityvDetails.Where(E => e.sad_id == item.sad_id).FirstOrDefault(); 






更新08/2014:
微软发布的功能要求,宣布的更新,他们开始进行这项工作:




因此,这里是我们的立场




  • 1),我们希望这是你做尽可能多的工作。这不是审查 - 这是正在进行中

  • 2),我们想出了如何使它发挥作用。它只是需要重写的所有

  • 3)我们正在改写了一切。

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







更新二千零十四分之十一:
微软终于在VS2015一些限制付诸实施。 读到这里。


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:

Expression cannot contain lambda expressions.

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

解决方案

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

Theres an open feature request for it.

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


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) 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.


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

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

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