我正在尝试查询嵌入在 .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/