如何在Azure数字孪生中进行不区分大小写的查询

huangapple go评论61阅读模式
英文:

How to make a case insensitive query in Azure Digital Twins

问题

query = digitalTwinsClientInstance.QueryAsync<BasicDigitalTwin>(
                @$"SELECT Child, Child.$metadata.$model
                FROM DIGITALTWINS
                    ...
                WHERE Area.$dtId = '{areaId}'

                  AND CONTAINS(LOWER(Child.Name), '{textFilter.ToLower()}')" // !! 不起作用
            );
英文:

So I have this code in C# that performs a query in DT

query = digitalTwinsClientInstance.QueryAsync<BasicDigitalTwin>(
                @$"SELECT Child, Child.$metadata.$model
                FROM DIGITALTWINS
                    ...
                WHERE Area.$dtId = '{areaId}'

                  AND CONTAINS(Child.Name, '{textFilter}')"
            );

However, I would like for the search to be case insensitive. Is there any way to do that in the query itself, since Azure DT dos not support UPPER or LOWER functions?

This is the functionality that I would like

query = digitalTwinsClientInstance.QueryAsync<BasicDigitalTwin>(
                @$"SELECT Child, Child.$metadata.$model
                FROM DIGITALTWINS
                    ...
                WHERE Area.$dtId = '{areaId}'

                  AND CONTAINS(LOWER(Child.Name), '{textFilter.ToLower()}')" // !! Does Not Work
            );

答案1

得分: 1

很遗憾,不支持在 ADT 中进行不区分大小写的查询。

一种可能的解决方法是在您的双子对象上存储一个第二属性,该属性包含相同的数据,但转换为小写。虽然不是理想的解决方案,但可以使用。

英文:

Unfortunately, no. There is native support for case-insensitive queries in ADT.

A possible workaround is to store a second property on your twin, with the same data but lowercase. Not ideal, but it works.

huangapple
  • 本文由 发表于 2023年6月16日 02:59:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76484751.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定