<legend id='OSRk4'><style id='OSRk4'><dir id='OSRk4'><q id='OSRk4'></q></dir></style></legend>
      • <bdo id='OSRk4'></bdo><ul id='OSRk4'></ul>

        <tfoot id='OSRk4'></tfoot>

        <i id='OSRk4'><tr id='OSRk4'><dt id='OSRk4'><q id='OSRk4'><span id='OSRk4'><b id='OSRk4'><form id='OSRk4'><ins id='OSRk4'></ins><ul id='OSRk4'></ul><sub id='OSRk4'></sub></form><legend id='OSRk4'></legend><bdo id='OSRk4'><pre id='OSRk4'><center id='OSRk4'></center></pre></bdo></b><th id='OSRk4'></th></span></q></dt></tr></i><div id='OSRk4'><tfoot id='OSRk4'></tfoot><dl id='OSRk4'><fieldset id='OSRk4'></fieldset></dl></div>
      1. <small id='OSRk4'></small><noframes id='OSRk4'>

        通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用

        时间:2023-08-02
        <legend id='S8b6V'><style id='S8b6V'><dir id='S8b6V'><q id='S8b6V'></q></dir></style></legend>
        • <bdo id='S8b6V'></bdo><ul id='S8b6V'></ul>
            <tfoot id='S8b6V'></tfoot>
          1. <small id='S8b6V'></small><noframes id='S8b6V'>

              <tbody id='S8b6V'></tbody>

              <i id='S8b6V'><tr id='S8b6V'><dt id='S8b6V'><q id='S8b6V'><span id='S8b6V'><b id='S8b6V'><form id='S8b6V'><ins id='S8b6V'></ins><ul id='S8b6V'></ul><sub id='S8b6V'></sub></form><legend id='S8b6V'></legend><bdo id='S8b6V'><pre id='S8b6V'><center id='S8b6V'></center></pre></bdo></b><th id='S8b6V'></th></span></q></dt></tr></i><div id='S8b6V'><tfoot id='S8b6V'></tfoot><dl id='S8b6V'><fieldset id='S8b6V'></fieldset></dl></div>

                  本文介绍了通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 Azure Functions 中使用 JavaScript 语言.使用 Cosmos DB 作为输入时,我无法将整数作为变量进行查询.例如,我有以下内容:

                  I'm using the JavaScript language in Azure Functions. When using Cosmos DB as the input, I cannot query by an integer as a variable. For example, I have the following:

                  使用 Azure Cosmos DB 作为我的输入的函数设置(公司).这是将分区键设置为 {partitionKey} 并将我的 SQL 查询设置为 SELECT * FROM c where c.random = {randomId}.

                  Function setup with Azure Cosmos DB as my input (companies). This is setup with the partition key as {partitionKey} and my SQL Query as SELECT * FROM c where c.random = {randomId}.

                  在函数的代码中,我发送了以下内容作为我的测试数据:

                  In the function's code, I've sent the following as my test data:

                  {
                      "randomId": 1,
                      "partitionKey": "prospect"
                  }
                  

                  有了这个,我没有得到任何结果.我已经确定我有一个 random 值为 1 的对象.

                  With this, I get no results. I've definitely verified that I have one object with random having a value of 1.

                  如果我要使用 random 向我的集合中添加一些值为 "1" 的内容,则可以使用以下方法:

                  If I were to add something to my collection with random with a value of "1", the following would work:

                  {
                      "randomId": "1",
                      "partitionKey": "prospect"
                  }
                  

                  我在 DocumentDB API 和 MongoDB API 上都试过了,这无关紧要,因为绑定是内置在 Azure Functions 中的.我在不同数据集上看到的趋势是,当您将整数参数绑定到查询或文档 ID 字段中的某些内容时,查询将不起作用.

                  I've tried this with both the DocumentDB API and MongoDB API, which shouldn't matter since the binding is built into Azure Functions. The trend I've seen with different sets of data is that querying just doesn't work when you bind a integer parameter to something in the query or Document ID field.

                  任何想法如何解决这个问题?

                  Any ideas how to fix this?

                  我已经通过可用的文档确认这在 C# 中有效.

                  I've confirmed this works in C# with the available documentation.

                  推荐答案

                  参考 Amor 对 一个类似的问题.首先,您可以按照此答案中的步骤创建 UDF 以将字符串值转换为整数.然后将 SQL Query 更改如下:

                  Refer to Amor's answer to a similar question. First, you can follow the steps in this answer to create a UDF to convert a string value to an integer. Then change the SQL Query as below:

                  SELECT * FROM c where c.random = udf.ConvertToNumber({randomId})
                  

                  这篇关于通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Azure Functions [JavaScript/Node.js] - HTTP 调用,良好实践 下一篇:什么是“X-Content-Type-Options=nosniff"?

                  相关文章

                  <small id='sC2Ib'></small><noframes id='sC2Ib'>

                • <tfoot id='sC2Ib'></tfoot>

                  1. <i id='sC2Ib'><tr id='sC2Ib'><dt id='sC2Ib'><q id='sC2Ib'><span id='sC2Ib'><b id='sC2Ib'><form id='sC2Ib'><ins id='sC2Ib'></ins><ul id='sC2Ib'></ul><sub id='sC2Ib'></sub></form><legend id='sC2Ib'></legend><bdo id='sC2Ib'><pre id='sC2Ib'><center id='sC2Ib'></center></pre></bdo></b><th id='sC2Ib'></th></span></q></dt></tr></i><div id='sC2Ib'><tfoot id='sC2Ib'></tfoot><dl id='sC2Ib'><fieldset id='sC2Ib'></fieldset></dl></div>
                      <bdo id='sC2Ib'></bdo><ul id='sC2Ib'></ul>

                  2. <legend id='sC2Ib'><style id='sC2Ib'><dir id='sC2Ib'><q id='sC2Ib'></q></dir></style></legend>