How to use DateTime in a SqlFilter with .NET

Have you been wondering how to use DateTime inside of SqlFilters, with your Topics/Subscriptions? Have you also noticed that this doesn't seem to work?

 var message = new BrokeredMessage();
message.Properties["datetime"] = DateTime.Now;

var sqlFilter = new SqlFilter("datetime > '2016-06-06'");

That's because you explicitly need to add the DateTime as a parameter, like so:

 var filter = new SqlFilter(" datetime >= @datetime");
filter.Parameters.Add("@datetime", DateTime.Parse("2016-06-06"));

In order to make this more searchable in the future, I have also added a corresponding StackOverflow question: