用RavenDb查询字典

时间:2011-04-27 07:16:17

标签: ravendb

我有一个定义为:

的类
public class Student
{
    public string Id { get; set; }
    public IDictionary<string, string> Attributes { get; set; }
}

基于我在此处发现的讨论:http://groups.google.com/group/ravendb/browse_thread/thread/88ea52620021ed6c?pli=1

我可以很容易地存储一个实例:

//creation
using (var session = store.OpenSession())
{               
    //now the student:
    var student = new Student();
    student.Attributes = new Dictionary<string, string>();

    student.Attributes["NIC"] = "studentsNICnumberGoesHere";               
    session.Store(student);
    session.SaveChanges();
}

但是,当我按如下方式查询时:

//Testing query on attribute
using (var session = store.OpenSession())
{
    var result = from student in session.Query<Student>()
                 where
                     student.Attributes["NIC"] == "studentsNICnumberGoesHere"
                  select student;

    var test = result.ToList();                
}           

我收到错误“'System.Linq.Expressions.InstanceMethodCallExpressionN'以输入'System.Linq.Expressions.MemberExpression'。”如图所示:

enter image description here 如何根据字典中的键进行查询?

1 个答案:

答案 0 :(得分:14)

这是一个错误,现在已修复。 将在下一个版本中出来,大约两个小时