0

Although, it is known that visual studio 2015 allows debugging of lambda expression and one can view it in immediate and watch window, I am still getting the error stating - Expression Cannot contain lambda expressions.

?lstClientDBs.Select(obj=>obj.ClientDatabase)
Expression cannot contain lambda expressions

Is there any option or something, I should've turned on? I am not able to debug or view the outcome of lambda expressions.

atp9
  • 890
  • 1
  • 11
  • 23
  • have you tried googling the exact error..? I found this among several when doing a `C# stackoverflow Experession cannot contain lamda expressions` http://stackoverflow.com/questions/23470607/expression-cannot-contain-lambda-expressions – MethodMan Jun 23 '16 at 18:15
  • @MethodMan - Yes. I did and none of them is solving the issue at hand. Please take a look at https://blogs.msdn.microsoft.com/visualstudioalm/2014/11/12/support-for-debugging-lambda-expressions-with-visual-studio-2015/ – atp9 Jun 23 '16 at 18:17
  • Does a Select statement actually work like that? I'm probably just brainfarting, but wouldn't you need a comparison in that statement as well? `lstClientDBs.Select(obj=>obj.ClientDatabase == x)` – pay Jun 23 '16 at 18:27

1 Answers1

1

Not sure about new feature in VS2015 but try setting the expression to a variable and then debug like

var data = lstClientDBs.Select(obj=>obj.ClientDatabase);

Strange but looks like MS declares that they have added that feature in VS2015 debugger (https://devblogs.microsoft.com/devops/support-for-debugging-lambda-expressions-with-visual-studio-2015/)

Also, you probably meant to use a Where() extension method than Select() like

var data = lstClientDBs.Where(obj=>obj.ClientDatabase);
Rahul
  • 76,197
  • 13
  • 71
  • 125