Even more Any and All

I was talking to a few people last week and one of them suggested another change in the any/all syntax. The more I looked at it the more I liked it. In fact when I asked a few of people over twitter it seemed everyone else liked it to.

The suggestion was to replace this:

~/Movies/?$filter=any(Actors a: any(a/Awards))

With this:

~/Movies/?$filter=Actors/any(a: a/Awards/any())

There are a couple of things I think are nice about this:

  • It looks a lot like code you might write in something like C# after replace '.'s with '/'s - as is the OData idiom - which hopefully will make it easier to learn.
  • It separates the collection variable (i.e. 'Actors') from the range variable (i.e. 'a'). I think this helps because using the old syntax people might be conditioned by the language they use every day to write: any(Actor a: …) instead of any(Actors a: …)

So I think we should do this.

But what do you think?
Alex

  1. Posted Wednesday, March 02, 2011 at 11:43:09 AM

    As someone that has communicated the need to query over lists with OData, I am very pleased to hear you are working on this. The inability to do this operation is a non-starter for OData in many applications. <br/> <br/> In XPath this query expression would look something like:<br/> <br/> Movies[/Actors/Actor][Awards/Award]<br/> <br/> Personally I am a huge XPath/XSLT fan and have been for many years. If you could match the expressiveness of XPath, at least for descendant operations, with OData, we'd have all the expressiveness we need.<br/>

  2. Posted Tuesday, February 15, 2011 at 12:22:11 PM

    Looks good and the new syntax reminds me of lambda in a way.<br/> <br/> I give my blessing if that means anything.