使用 RavenDb 查询字典 [英] Querying a Dictionary with 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
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();
}
我收到错误'System.Linq.Expressions.InstanceMethodCallExpressionN' to type 'System.Linq.Expressions.MemberExpression'."如图:
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?
推荐答案
这是一个错误,现已修复.将在下一个版本中发布,大约两个小时后
This is a bug, it is fixed now. Will be out in the next build, in about two hours
这篇关于使用 RavenDb 查询字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!