2015-07-12 64 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)。確保那些匹配。