您好,我在使用时遇到错误
query = query.Where(r => r.Features.ContainsValue(fuelType));
这是我的模型
public class VehicleResponse
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
public Vehicle Vehicle { get; set; }
public List<string> PhotoUrls { get; set; }
public string VideoUrl { get; set; }
public Dictionary<string, string> Features { get; set; }
public List<string> Equipments { get; set; }
public VehicleResponse()
{
this.PhotoUrls = new List<string>();
}
}
DocumentDB 不支持“ContainsValue”方法。那么我应该如何更改 LINQ 查询呢?
谢谢。
最佳答案
如果您像这样定义您的功能:
"Features": {
"TKey": "TK1",
"TValue": "TV1"
}
您可以将其更改为: query = query.Where(r => r.Features["TKey"].Contains("T"));
您可以阅读documents获取更多信息。
关于c# - Azure DocumentDB,使用 LINQ 在字典中搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37110424/