Raymond Starkey
Raymond Starkey

Reputation: 21

DocumentDB SQL string works in Query Explorer but not in C# code

When I run this query in the Query Explorer…

Select quote from sqs quote
join product in quote.QuotedProductList 
join part in product.PartNumberList 
WHERE part.id = 'Part-XXXX-XX' AND quote.QuoteStatus = 'Draft'

..in DocumentDB I get two quotes with the appropriate product and part data showing in the results pane; this is correct. But, when I create the same query in C# I get two quote objects returned that have been created by the constructor but there is no data from the database…

List<Quote> hits = new List<Quote>();
            string sql = "Select quote from sqs quote join product in quote.QuotedProductList join part in product.PartNumberList WHERE part.id = '" + partNumber + "' AND quote.QuoteStatus = 'Draft'";
hits = Client.CreateDocumentQuery<Quote>(Collection.DocumentsLink, sql).ToList();

Can anyone explain why this happening?

Upvotes: 0

Views: 164

Answers (1)

Howard Edidin
Howard Edidin

Reputation: 63

Try this

Select quote.quote from sqs quote join product in quote.QuotedProductList join part in product.PartNumberList WHERE part.id = '" + partNumber + "' AND quote.QuoteStatus = 'Draft'";

Upvotes: 1

Related Questions