英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论