c# - Azure DocumentDB,使用 LINQ 在字典中搜索

标签 c# linq azure azure-cosmosdb nosql

您好,我在使用时遇到错误

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/

相关文章:

c# - 列出目录+子目录中的所有文件和目录

c# - .NET Portable - 在字符串上调用 .Select()

c# - 如何在使用 linq 维护对象的原始形式的同时过滤列表中的列表?

c# - 是否可以处理 LINQ 查询中的异常?

azure - 应用服务日志 12 小时后未关闭

azure - 如何获得检测到的实体的置信度得分?

c# - 带通配符的真值表(ish)

javascript - 如何将文件返回给用户?

表示 const 字符串的 C# 类属性

python - azure ml 实验返回与 webservice 不同的结果