Azure DocumentDB,使用 LINQ 在字典中搜索
Azure DocumentDB , Search In Dictionary with LINQ
嗨,我在使用
时遇到错误
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.Where(r => r.Features["TKey"].包含("T"));
您可以阅读 documents 以获取更多信息。
嗨,我在使用
时遇到错误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.Where(r => r.Features["TKey"].包含("T"));
您可以阅读 documents 以获取更多信息。