Guid[]:如何从 Cosmos DB 查询和获取详细信息?
Guid[]:How to query and fetch details from Cosmos DB?
我正在使用 Azure CosmosDB。我有下面的 GetProgramsByStudentIDAsync 方法,它需要获取与学生 ID 关联的所有程序(请注意,学生 ID 的类型为 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[] 不包含 'Contains' 的定义,最佳扩展方法重载需要类型为
的接收器
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; }
}
请提前assist.Thanks!!!
尝试显式转换为 guid
using FeedIterator<ProgramContainer> feedIterator =
programContainer.GetItemLinqQueryable<ProgramContainer>()
.Where(x => studentIds.Contains((Guid)x.StudentId)).ToFeedIterator();
我正在使用 Azure CosmosDB。我有下面的 GetProgramsByStudentIDAsync 方法,它需要获取与学生 ID 关联的所有程序(请注意,学生 ID 的类型为 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[] 不包含 'Contains' 的定义,最佳扩展方法重载需要类型为
的接收器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; }
}
请提前assist.Thanks!!!
尝试显式转换为 guid
using FeedIterator<ProgramContainer> feedIterator =
programContainer.GetItemLinqQueryable<ProgramContainer>()
.Where(x => studentIds.Contains((Guid)x.StudentId)).ToFeedIterator();