Interrogazione di un dizionario con RavenDB
-
22-10-2019 - |
Domanda
Ho una classe definita come:
public class Student
{
public string Id { get; set; }
public IDictionary<string, string> Attributes { get; set; }
}
Sulla base della discussione che ho trovato qui: http: / /groups.google.com/group/ravendb/browse_thread/thread/88ea52620021ed6c?pli=1
posso archiviare un caso abbastanza facilmente come:
//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();
}
Tuttavia quando interrogo come qui sotto:
//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();
}
ottengo l'errore " 'System.Linq.Expressions.InstanceMethodCallExpressionN' digitare 'System.Linq.Expressions.MemberExpression'." come indicato:
Come posso query basata su una chiave nel dizionario?
Soluzione
Questo è un bug, è fissato ora. Uscirà nella prossima generazione, in circa due ore
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow