热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

适用于WHEREIN的AzureCosmosDBSQLAPIQueryDefinition多个参数

如何解决《适用于WHEREIN的AzureCosmosDBSQLAPIQueryDefinition多个参数》经验,是哪儿的问题?

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

var compOnentDesignGuids= new List();
// ...
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}\""))));

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


推荐阅读
author-avatar
无限制空间689
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有