适用于WHERE IN的Azure Cosmos DB SQL API QueryDefinition多个参数

Sco*_*y H 5 azure azure-cosmosdb azure-cosmosdb-sqlapi

我正在尝试将SQL查询参数与WHERE ... INAzure Cosmos DB SQL API查询中的语句一起使用:

var componentDesignGuids = new List<Guid>();
// ...
var queryDefinition = new QueryDefinition(
        "SELECT componentDesign.guid, componentDesign.component.name, componentDesign.component.componentType " +
        "FROM components componentDesign " +
        "WHERE componentDesign.guid IN (@componentDesignGuids)")
    .WithParameter("@componentDesignGuids", string.Join(",", componentDesignGuids.Select(guid => $"\"{guid}\""))));
Run Code Online (Sandbox Code Playgroud)

但这会导致查询,其中被替换的参数是单个字符串,例如IN ("guid0, guid1, guid2")。由于这是一个IN子句,因此我想在其中放置不确定数量的字符串,例如IN ("\"guid0\", \"guid1\", \"guid2\"")。我意识到我可以使用插值字符串来完成这项工作,但是我希望输入尽可能安全以防止注入。如何使用QueryDefinition和/或指定此内容WithParameter