user1730289
user1730289

Reputation: 477

Azure Cosmos DB Query

I need to query by User ID but I think the period is messing with my query. I tried the following 3 queries. The Bracket and Quotes give me an error and the 1st does not produce and error but no results.

SELECT * FROM c WHERE c.document.BotAccessors.BotState.Profile.UserId = "5351ec9f-46fb-449a-b6f5-1ea07e683015"
SELECT * FROM c WHERE c.document.[BotAccessors.BotState].Profile.UserId = "5351ec9f-46fb-449a-b6f5-1ea07e683015"
SELECT * FROM c WHERE c.document."BotAccessors.BotState".Profile.UserId = "5351ec9f-46fb-449a-b6f5-1ea07e683015"

{
    "document": {
        "BotAccessors.BotState": {
            "Version": 4,
            "ConversationState": 0,
            "FirstMessageDateTime": "2020-03-04T13:19:20.7657389Z",
            "FirstMessage": null,
            "LastSeenDateTimeTicks": 637189282249482900,           
            "Profile": {
                "UserId": "5351ec9f-46fb-449a-b6f5-1ea07e683015",
            }
        }
    },
    "_etag": "\"0300fbab-0000-0700-0000-5e5fb85e0000\"",
    "_rid": "4zYrANO8oXoBAAAAAAAAAA==",
    "_self": "dbs/4zYrAA==/colls/4zYrANO8oXo=/docs/4zYrANO8oXoBAAAAAAAAAA==/",
    "_attachments": "attachments/",
    "_ts": 1583331422
}

Upvotes: 1

Views: 355

Answers (1)

Kane
Kane

Reputation: 16812

You need to use square brackets with quotes for property names with non a-zA-Z0-9 characters. Here is an example:

SELECT * FROM c WHERE c["document"]["BotAccessors.BotState"]["Profile"]["UserId"] = "5351ec9f-46fb-449a-b6f5-1ea07e683015"

Upvotes: 1

Related Questions