Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
378 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...