我有一个类定义为:
public class Student
{
public string Id { get; set; }
public IDictionary<string, string> Attributes { get; set; }
}
根据我在这里找到的讨论:http ://groups.google.com/group/ravenb/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' to type 'System.Linq.Expressions.MemberExpression'。” 如图所示:
如何根据字典中的键进行查询?