SQLFilter based on System Properties in Azure Service Bus Subscription
<p>I am working on setting up a topic/subscription service, and need help with the syntax of my SQLFilter so I can access BrokeredMessage Properties, specifically the To property. What is the correct syntax on a SQL Filter to access the System Properties of the message?</p>

<p>I have a working example using this tutorial where I can send and receive to my topic/subscriptions as desired: <a href="https://azure.microsoft.com/en-us/documentation/articles/service-bus-queues-topics-subscriptions/" rel="nofollow">https://azure.microsoft.com/en-us/documentation/articles/service-bus-queues-topics-subscriptions/</a></p>

<p>However, now I want to setup SQL filters for each subscription based on the To property of the BrokeredMessage. The tutorial I followed mentions that it is possible "When a subscription is created, you can supply a filter expression that operates on the properties of the message, both the system properties (for example, Label) and custom application properties (for example, StoreName.)"</p>

<p>If I set a custom property, e.g. StoreName, like this:</p>

<pre class="lang-C# prettyprint-override"><code>message.Properties.Add("StoreName", "TestMe");
</code></pre>

<p>and set the subscription up with a SQL Filter like this:</p>

<pre class="lang-C# prettyprint-override"><code>namespaceManager.CreateSubscription("MyNSTestTopic", "TestSubscription", new SqlFilter("StoreName = 'TestMe'"));
</code></pre>

<p>The subscription filters as expected. However, if I try and use the BrokeredMessage objects To property (or label for that matter) as described in the article, I have been unable to get it to work. I've tried the following SQL Filters with no luck. What is the correct syntax to access the System Properties of the message?</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>BrokeredMessage message = new BrokeredMessage();
message.To = "TestMe";

namespaceManager.CreateSubscription("MyNSTestTopic", "TestSubscription", new SqlFilter("To = 'TestMe'"));
namespaceManager.CreateSubscription("MyNSTestTopic", "TestSubscription", new SqlFilter("Message.To= 'TestMe'"));
namespaceManager.CreateSubscription("MyNSTestTopic", "TestSubscription", new SqlFilter("MessageTo= 'TestMe'"));
namespaceManager.CreateSubscription("MyNSTestTopic", "TestSubscription", new SqlFilter("messageto= 'TestMe'"));</code></pre>
</div>
</div>
</p>