2013-02-01 99 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