1

I am having a challenge retrieving data from my DocumentDB using C#.

I get the expected results when I run the query below in my Azure DocumentDB data explorer. Ignore the use of contains query, it's a dynamically crafted query

select distinct c.model from c   where  ( CONTAINS (c.manufacturer, \"BMW\") )

Attempting to run the same query on c# gives me an error

var dblink = UriFactory.CreateDocumentCollectionUri(ConfigurationManager.AppSettings["DocumentDbDatabase"], "Conversation");
var models = _dbclient.CreateDocumentQuery<dynamic>(dblink, "select distinct c.model from c   where  ( CONTAINS (c.manufacturer, "BMW") )").ToList();

The error I get is incorrect syntax near distinct

Where is the error emanating from?

Masinde Muliro
  • 1,175
  • 3
  • 24
  • 38

1 Answers1

0

You may want to upgrade to the latest .Net SDK (v1.22.0).

The syntax error here is from the SDK rather than the query service, given that support for DISTINCT was added recently. Upgrading to the latest SDK should fix the issue.

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
Samer Boshra
  • 869
  • 5
  • 6