c# - 如何在 RavenDB 上查询子元素?

标签 c# .net database ravendb

我正在尝试查询嵌入在 .NET 中的 RavenDB 上的子元素,文本搜索工作正常,但 WhereBetweenOrEqual、WhereGreaterThan、WhereLessThan 不工作

我的代码:

public class Document
{
    public string Id { set; get; }
    public IEnumerable<Attribute> Attributes { set; get; } 
}

public class Attribute
{
    public string Key { set; get; }
    public object Value { set; get; }
}

摘要索引类

public class Document_ByAttribute : AbstractIndexCreationTask<Document>
{
    public Document_ByAttribute()
    {
        Map = documents => from doc in documents
                          select new
                          {
                              _ = doc.Attributes
                                 .Select(attribute =>
                                     CreateField(attribute.Key, attribute.Value, false, true))
                          };
    }
}

这是工作

    public ActionResult Filter(string id)
    {
        var doc = _Session.Advanced.LuceneQuery<Document>("Document/ByAttribute").Search("Title", "*" + id + "*").ToList();
        return Json(doc, JsonRequestBehavior.AllowGet); 
    }

这个函数不工作

    public ActionResult Price_Range(decimal min = 0, decimal max = 99999999)
    {
        var doc = _Session.Advanced.LuceneQuery<Document>("Document/ByAttribute").WhereBetweenOrEqual("Price", min, max).ToList();
        return Json(doc, JsonRequestBehavior.AllowGet); 
    }

我已经尝试了一切。我没有成功。 请帮我。怎么办?

提前致谢。

最佳答案

可能的问题是类型。 您传递的是小数,但服务器上的值是以其他方式解释的(可能是 float 或 int)。确保它们匹配。

关于c# - 如何在 RavenDB 上查询子元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31371365/

相关文章:

c# - BindingSource 上的 EndEdit 更新 DataTable,但 rowstate 仍未改变

c# - C#条件编译中有OR运算符吗?

c# - 使用私有(private)构造函数对类进行单元测试

php - MySQL:根据另一个表数据选择一个表(用于电子邮件)

mysql - 在 MariaDB/MySQL 中无锁地删除?`(InnoDB)

c# - 使用 Json Key 绑定(bind)图片源 url

c# - 后台服务不工作 Xamarin.Android

html - 处理 HTML 表单的最有效方法

c# - 如果我没有为 CSharpCodeProvider 指定 CompilerVersion 会发生什么,为什么大多数示例都指定了它?

c# - Facebook 应用程序如何工作?