在documentDB中按子字符串搜索 [英] search by substring in documentDB
问题描述
这是示例documentDB文档,
this is the sample documentDB document,
我想获取所有在一个或多个主题上不及格的文档
I want to get all the documents who failed in one or more subjects
我发现了类似的东西
SELECT
*
FROM students s
JOIN c IN s.subjects
WHERE c.result = "pass"
我想使用C#代码进行检索
I want to retrieve by using c# code
{
"id": "0066a253-f042-4213-b06e-65b1ea1e49aa",
"name": "Sunny",
"rollNo": 123,
"class": "2nd",
"section": "B",
"Department": {
"name": "CSE",
"id": "cse",
"subjects": [
{
"id": "subject-1",
"marksObtained": 66,
"maxMarks": 100,
"result": "pass"
},
{
"id": "subject-2",
"marksObtained": 56,
"maxMarks": 75,
"result": "pass"
},
{
"id": "subject-3",
"marksObtained": 22,
"maxMarks": 100,
"result": "fail"
},
{
"id": "subject-4",
"marksObtained": 36,
"maxMarks": 50,
"result": "pass"
},
{
"id": "subject-5",
"marksObtained": 16,
"maxMarks": 100,
"result": "fail"
}
]
},
"Type": "Student"
}
我这样尝试过
var result = client.CreateDocumentQuery<dynamic>(dc.SelfLink, "SELECT s.id as id,s.Name as Name,s.Age as Age,s.section as section,s.subjects as subjects FROM students s JOIN c IN s.subjects WHERE c.result = \"pass\"").ToList();
List<Student> students = new List<Student>();
foreach(var std in result)
{
students.Add((Student)std);
}
我正在获取类似上面的代码,但是即使我给了pa或pas或pass或p或ass或那样的东西,我也应该得到一些我需要在SQL中具有LIKE功能的东西
Something like above is my code I am getting, but Even I give pa or pas or pass or p or ass or as then also I should get something I need a functionality of LIKE in SQL
对此有什么解决方案吗? 我需要SQL中的LIKE功能才能从documentDB检索数据
Is there any solution for this?? I need LIKE functionality in SQL to retrieve data from documentDB
推荐答案
Update: As of 5/6/15, DocumentDB added a set of String functions including STARTSWITH
, ENDSWITH
, and CONTAINS
. Please note that most of these functions do not run on the index and will force a scan.
尚未在DocumentDB中实现通配符,例如SQL的LIKE'%%'.
Wildcards like SQL's LIKE '% %' has not been implemented in DocumentDB yet.
请在> DocumentDB的反馈论坛上发表您的意见并对该功能进行投票.
这篇关于在documentDB中按子字符串搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!