如何在ravendb中写入字符串数组索引 [英] how to write string array index in ravendb

查看:52
本文介绍了如何在ravendb中写入字符串数组索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 Orders 的 ravendb 文档

i have ravendb document called Orders like this

{
"MyOrders": [
    "S1",
    "S2"
],

"Id": "6666"
}

我将查询此文档并传递订单字符串,例如 S1然后它应该返回给我那个文件,因为 S1 匹配它.我对这个 ravendb 很陌生.我无法找到方法.到目前为止我只写了这个

I will query this document and pass order string for example S1 Then it should return me that document as S1 matches it. I am pretty new to this ravendb. I am unable to find way. I have written only this so far

   public class MyOrderIndexes: AbstractIndexCreationTask<Order>
{

    public MyOrderIndexes()
    {
        Map = Orders => from Order in Orders
                                 select new
                                             {
                                                 ID= Order.Id
                                             };
        Index(x => x.Id, FieldIndexing.NotAnalyzed);
    }
}

谁能帮帮我

推荐答案

要查询,您不需要创建索引.只需进行查询,Raven 就会为您创建.

To query that, you don't need to create an index. Just do a query, Raven will create it for you.

这个查询应该可以正常工作:

This query should work just fine:

var hasS2 = session.Query<Orders>()
   .Where(o => o.MyOrders.Contains("S2"))
   .ToList();

这篇关于如何在ravendb中写入字符串数组索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆