我有一个类定义为:查询辞典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'”。如图所示:
如何根据字典中的键进行查询?
刚刚证实,它可以在不稳定的版本350中正常工作:http://builds.hibernatingrhinos.com/builds/ravendb-unstable – basarat 2011-04-30 21:46:34