使用客户端 api 在 ravendb 中选择many的解决方法
我有一个像这样的 ravendb 类:
public class Student
{
public string Id { get; set; }
public string TopLevelProperty { get; set; }
public Dictionary<string, string> Attributes { get; set; }
public Dictionary<string,List<Dictionary<string, string>>> CategoryAttributes { get; set; }
}
和一个像这样的文档:
由于 selectmany,以下 linq 将无法工作:
test = (from student in session.Query()
from eduhistory in student.CategoryAttributes["EducationHistory"]
where eduhistory["StartYear"] == "2009"
select student).ToList();
How can I get all Students where StartYear == 2009 年?
I have a ravendb class like such:
public class Student
{
public string Id { get; set; }
public string TopLevelProperty { get; set; }
public Dictionary<string, string> Attributes { get; set; }
public Dictionary<string,List<Dictionary<string, string>>> CategoryAttributes { get; set; }
}
and a document like so:
The following linq will not work due to a selectmany:
test = (from student in session.Query()
from eduhistory in student.CategoryAttributes["EducationHistory"]
where eduhistory["StartYear"] == "2009"
select student).ToList();
How can I get all students where StartYear == 2009?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这样做是这样的:
注意 EducationHistory 后面的逗号而不是点。这表明我们正在查看列表以查找名为 StartYear 的项目之一中的属性。
如果我想要大于:
等等等等。
This does it :
Notice the comma rather than a dot after EducationHistory. This indicates that we are looking at the list to find a property in one of the items named StartYear.
If I wanted greater than :
etc etc.
这应该有效:
This should work: