浏览代码

班级名单获取

zhouj1203@hotmail.com 4 年之前
父节点
当前提交
fe01d2087f
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      TEAMModelOS/Controllers/School/ClassRoomController.cs

+ 8 - 2
TEAMModelOS/Controllers/School/ClassRoomController.cs

@@ -419,10 +419,16 @@ namespace TEAMModelOS.Controllers
             try
             {
                 var client = _azureCosmos.GetCosmosClient();
-                List<string> id = ids.ToObject<List<string>>();
+                //List<string> id = ids.ToObject<List<string>>();
+                string info = "";
+                for (int i = 0; i < ids.GetArrayLength(); i++)
+                {
+                    //ids.Add(id[i].ToJsonString());
+                    info += ids[i].ToJsonString() + ",";
+                }
                 List<object> ClassName = new List<object>();
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(
-                    queryText: $"select c.id,c.name from c where c.id in '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
+                    queryText: $"select c.id,c.name from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)