2013-02-01 44 views
0

文档结构:乌鸦查询抛出异常

class UserAccountInfo 
{ 
     public String Id { get; set; } 
     public AccountType AccountType { get; set; }Servicetax 
     public String MainAccountMobileNo { get; set; } 
     public UserStatus Status { get; set; } 
     public String EmailId { get; set; } 
     public String DisplayName { get; set; } 
     **public Object User { get; set; }** 
} 

对象存储是在账户类型中提到的任何类型的实例。存储在对象中的类型可以使用Accountype for ex来查找;如果Accountype是客户,那么存储在对象中的实例将是AccountinfoCustomer等。所以使用我试图查询,但从乌鸦获得以下例外。

var Result = sess.Query<UserAccountInfo>().Where(x => x.AccountType == usertype && ((AccountInfoCustomer)x.User).Customerstatus == CustomerStatus.Pending); 

{ “URL:\”?/索引/动态/ UserAccountInfos查询= ACCOUNTTYPE%253ADistributor%2520AND%2520User).Customerstatus%253APending &开始= 0 &的pageSize = 128 &聚集=无\“\ r \ n \ r \ nSystem.ArgumentException:字段 ')_Customerstatus' 不被索引,不能在未在Raven.Database.Indexing.Index.IndexQueryOperation.AssertQueryDoesNotContainFieldsThatAreNotIndexes()

回答

0

此索引\ r \ n场查询应该工作。经测试,在当前的稳定RavenDB 2.0.2230。

测试在这里:https://gist.github.com/4692351

你在一个旧版本?

+0

马特。我已经将构建版本更改为最新版本2.0.2230。仍然不为me.And工作异常我得到的是[System.InvalidOperationException] = { “URL:\”。?/索引/动态/ UserAccountInfos查询=用户).Customerstatus%253APending&开始= 0&的pageSize = 128&聚集=无\ “\ r \ n \ r \ nLucene.Net.QueryParsers.ParseException:无法解析: '用户).Customerstatus:待定' ---> Lucene.Net.QueryParsers.ParseExcept ...有没有,你有什么具体的图书馆添加到得到执行此查询。 – user1811801

+1

对不起马特..这是我的错,我没有更新乌鸦客户端库,这就是导致问题的原因。现在,它的工作谢谢 – user1811801