2011-04-27 89 views
6

我有一个类定义为:查询辞典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 如何根据字典中的键进行查询?

+0

刚刚证实,它可以在不稳定的版本350中正常工作:http://builds.hibernatingrhinos.com/builds/ravendb-unstable – basarat 2011-04-30 21:46:34

回答

12

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

+3

永远是一种荣幸,阅读任何你写 – basarat 2011-04-29 16:40:40