我有一個類定義爲:查詢辭典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