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.
If you still need to use Visual Studio 2010 or 2013, you can use lambda expressions in the package manager console. For details, please see my SO post here:
Why is it not possible to evaluate lambdas in the immediate window?
This is the original source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With