RavenDB query index with custom fields names

≯℡__Kan透↙ 提交于 2019-12-11 03:16:01

问题


I have collection of documents Message in RavenDB. Definition:

class Message
{
    string Content;
    Tag[] Tags;
}

class Tag
{
    string Value;
}

And i have index:

from doc in docs.Messages
from docTagsItem in (IEnumerable<dynamic>)doc.Tags
select new { Content = doc.Content, TagsValue = docTagsItem.Value }

Here we have field with name TagsValue which isn't part of class Message, that's why i can't using

Session.Query<Message>(indexName).Where(m=>m.TagsValue==tagValue)

How should query this index from .NET by TagValue? Should i use Advanced.LuceneQuery?


回答1:


Because you use Linq you need to create a type with that property to query that, or you can use Lucene API.

Note that you don't actually need to make a query like that using a static index, you can do that using just dynamic indexes and pure linq.



来源:https://stackoverflow.com/questions/7411671/ravendb-query-index-with-custom-fields-names

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