How to do a Dump

LINQPad is a nice piece of software for testing LINQ queries (or any other code, really!)

The default input method (or ‘language’) is set to “Expression”. However, using the “Statement(s)” language, you can enter more than 1 line of code and it will evaluate it for you.

To inspect a LINQ statement using Statements (like Expression gives you), though, requires the use of the Dump() extension method.

Like so:

var i = new int[] { 2, 4 };
var t = a.Where(x => x.b.Select(c => c.d).Any(e => i.Contains(e)));

You can run as many Dump()s as you want. They appear in the order they were run in the Results pane.

Dump() returns the original object too. So if you really want, you can chain them to get multiple results of the same thing.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s