2015-07-12 37 views
3

我想查询在.NET上RavenDB嵌入式子元素,文本搜索工作,但WhereBetweenOrEqual,WhereGreaterThan,WhereLessThan不工作如何查询RavenDB上的子元素?

我的代码:

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)) 
          }; 
    } 
} 

This is Working

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); 
    } 

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

在此先感谢。

回答

0

可能的问题是类型。 您正在传递一个十进制数,但服务器上的值以其他方式解释(可能是float或int)。确保那些匹配。