[英]Guid[]:How to query and fetch details from Cosmos DB?
我正在使用 Azure CosmosDB。 我有下面的 GetProgramsByStudentIDAsync 方法,該方法需要獲取與 studentID 關聯的所有程序(請注意, studentID 的類型是 Guid )。
using Microsoft.Azure.Cosmos;
using Microsoft.Azure.Cosmos.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Threading.Tasks;
public async Task<ProgramContainer> GetProgramsByStudentIDAsync(Guid[] studentIds)
{
var db = Client.GetDatabase(databaseId);
var programContainer = db.GetContainer(containerId);
using FeedIterator<ProgramContainer> feedIterator = programContainer.GetItemLinqQueryable<ProgramContainer>()
.Where(x => studentIds.Contains(x.StudentId)).ToFeedIterator(); //Giving me error at studentIds.Contains Please find the error details below:
CS1929:Guid[] 不包含“包含”的定義,並且最佳擴展方法重載需要類型為接收器
ProgramContainer class 供參考:
public class ProgramContainer
{
public string ProgramName{ get; set; }
public string ProgramCode { get; set; }
public Guid StudentId { get; set; }
public bool IsActive { get; set; }
}
請協助。提前致謝!!!
嘗試顯式轉換為 guid
using FeedIterator<ProgramContainer> feedIterator =
programContainer.GetItemLinqQueryable<ProgramContainer>()
.Where(x => studentIds.Contains((Guid)x.StudentId)).ToFeedIterator();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.