使用 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”。”如图所示:
如何根据字典中的某个键进行查询?
I have a class defined as:
public class Student
{
public string Id { get; set; }
public IDictionary<string, string> Attributes { get; set; }
}
based on the discussion I found here : http://groups.google.com/group/ravendb/browse_thread/thread/88ea52620021ed6c?pli=1
I can store an instance quite easily as :
//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();
}
However when I query it as below:
//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();
}
I get the error "'System.Linq.Expressions.InstanceMethodCallExpressionN' to type 'System.Linq.Expressions.MemberExpression'." as shown:
How can I query based on a key in the dictionary?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个错误,现已修复。
将在下一个版本中发布,大约两个小时后
This is a bug, it is fixed now.
Will be out in the next build, in about two hours