Querying a Dictionary with RavenDb

僤鯓⒐⒋嵵緔 提交于 2019-12-07 02:48:36

问题


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?

回答1:


This is a bug, it is fixed now. Will be out in the next build, in about two hours



来源:https://stackoverflow.com/questions/5800685/querying-a-dictionary-with-ravendb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!