开发者

Why does .Dump(#) cause my results to double?

开发者 https://www.devze.com 2023-04-10 22:29 出处:网络
When I run an OData query with LinqPad, I sometimes need more than the standard 3 levels of nesting/expanding.

When I run an OData query with LinqPad, I sometimes need more than the standard 3 levels of nesting/expanding.

I found online that y开发者_运维百科ou can call Dump(int nestingLevel) to get more levels of nesting.

But when I do that I get two result sets. (One with my expanded nesting, and one as it would be without the .Dump call.)

Why is that? Is there a way I can turn that off?

As an example connect to https://data.stackexchange.com/stackoverflow/atom and run this query:

Posts.Take(1).Select(x=>new{x.Title}).Dump(1)

You will get two identical result sets. Like this:

Why does .Dump(#) cause my results to double?


When you run a C# Expression query, the query's result is automatically dumped.

LINQPad compiles the code

LINQPad.Dump(
    //Your code here
);

Your code calls Dump() too, so you're dumping the object before returning to the outer generated Dump() call.
(Dump() returns its argument to allow chaining)

You only need to Dump() in a C# Statements (or higher) query, or if you want to dump something else.

0

精彩评论

暂无评论...
验证码 换一张
取 消