Pavel Nasovich's Blog The Moderately Enthusiastic Programmer

Today I Learned: Azure Cosmos Db: Query for Fields not defined

There are several ways:

Using LINQ

For anyone who wants a Linq solution, it’s:

query.Where(d => !d.SomeField.IsDefined())


To get the IsDefined extension method, you need to add Microsoft.Azure.Documents.SystemFunctions namespace

Using SQL Query Grammar with built-in functions

IS_DEFINED (expr) - returns a Boolean indicating if the property has been assigned a value.

SELECT TOP {0} * FROM Telemetry t WHERE (is_defined(t.longitude) OR is_defined(t.latitude))

Thanks to Azure Feedback and Azure Cosmos DB SQL syntax reference

comments powered by Disqus