【发布时间】:2018-03-25 21:47:10
【问题描述】:
使用 mongodb-csharp 驱动 (https://github.com/mongodb/mongo-csharp-driver)
我有以下类和枚举:
public enum PropertyType {
Unknown,
Age,
Weight,
Gender
}
public class Data {
public Dictionary<PropertyType, Int32> Props {get;set;}
}
我可以读取和保存如下所示的数据。
{
Props: {
1: 28,
2: 220,
3: 0
}
}
我不能做的是用 Props[PropertyType.Age] == 28 查询“数据”.. 见下面的代码:
var data = from d in collection where d.Props[PropertyType.Age] == 28 select d;
我得到的错误是:
System.InvalidOperationException: 'data.Props.get_Item(PropertyType.Age) 不受支持。'
帮助我obiwan kenobi你我唯一的希望。
【问题讨论】:
标签: mongodb mongodb-.net-driver