Answer to the Batching Brainteaser

Earlier this week I posted a little batching brainteaser from our internal team discussion list. If you have a cheesy drumroll sound on your computer now is the time to start playing it, 'cause here comes the answer:

a) 0

Yep, that's right, zero. Thomas is the winner for giving the correct answer twice, for two very different reasons (one of which actually made me laugh out loud). The reasoning in his second answer is roughly correct.

When using metadata during batching with an item name, such as '%(Foo.Identity)'=='%(Bar.Identity)', the item name is included in the comparison. Since "foo" never equals "bar" the condition in the example is always false and nothing gets printed.

To make the XML print three lines, which is what you'd expect, you actually don't have to use a condition at all. You just need to put %(Identity) into the message somewhere, like this:

<

Message Text="@(Foo) @(Bar) %(Identity)"/>

This looks completely bizarro, I admit, but does result in the following output:

a a a
b b b
c c c

Batching. What could be more fun? Mad props to Sumedh for helping to explain all this to me.

[ Author: Neil Enns ]