Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging LINQ - Children could not Be evaluated

Tags:

c#

linq

I'm trying to understand why I can't inspect a returned value from a LINQ query when on a breakpoint. Expanding the results view simply says "Children Could Not Be Evaluated".

On the other hand enumerating with a foreach in code or using a ToList does let the collection be inspected in the debugger.

I would have thought, as it does it most other scenarios, expanding results in the debugger is equivalent to a ToList on the collection which is why I'm expecting it to work. The only thing that is a little different is that I'm calling from an EXE into a DLL, the DLL being where the objects are defined and the initial query built and returned. But I can't see it being that.

var timeboxes = assetRepo.ActiveTimeboxes();

// This can't be evaluated in the debugger
var stories = timeboxes.SelectMany(c => assetRepo.AllStories(c));

// This can be inspected in the debugger
var executedStories = stories.ToList();
like image 529
Daniel Revell Avatar asked Dec 27 '25 16:12

Daniel Revell


1 Answers

It's not possible to debug from VS, but I there is LINQPad that could sometimes help you.

Your best option is to split your query into small statements.

like image 199
Cybermaxs Avatar answered Dec 30 '25 05:12

Cybermaxs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!