2011-07-14 54 views
0

給出這樣的功能:ActiveRecord的LINQ的/ NHibernate的LINQ的不是建立查詢完全

Public Function Search(ByVal StartIndex As Integer, _ 
ByVal MaxResults As Integer, _ 
ByVal AccountNumber As String, _ 
ByVal LastName As String, _ 
ByVal FirstName As String, _ 
ByVal DateOfService As String, _ 
ByVal CPTCode As String, _ 
ByVal Contract As String, _ 
ByVal ClaimNumber As String, _ 
ByVal PaidAmount As String, _ 
ByVal CheckNumber As String, _ 
ByVal SortExpression As String, _ 
ByRef count As Integer) As RemitLineItemEntity() 

我試圖建立地方在一個時間從句一塊基於傳遞到函數,像這樣的參數:

If Not String.IsNullOrEmpty(AccountNumber) Then 
     If AccountNumber.Contains("%") Then 
      remits = remits.Where(Function(r) r.MedicalRecordNumber Like AccountNumber.Replace("%", "*")) 
     Else 
      remits = remits.Where(Function(r) r.MedicalRecordNumber = AccountNumber) 
     End If 
    End If 
    If Not String.IsNullOrEmpty(LastName) Then 
     If LastName.Contains("%") Then 
      remits = remits.Where(Function(r) r.LastName Like LastName.Replace("%", "*")) 
     Else 
      remits = remits.Where(Function(r) r.LastName = LastName) 
     End If 
    End If 

...更多,如果其他PARAMS

 _log.Debug("Start Count query") 
     count = remits.Count() 
     _log.Debug("End Count query") 

調用此功能的Wi聲明個姓氏=「史密斯」,當我到了count=remits.Count()線,看SQL事件探查器它會產生這樣的SQL(從什麼NHibernate的產生美化了一番):

Select count(*) from remitline 

,而不是我所期待的:

Select count(*) from remitline where lastname = "smith" 

我在做什麼錯誤建立where子句?我使用的是城堡的ActiveRecord 2.1

TIA

回答

0

更新至最新版本的ActiveRecord(3.0 RC)和這個問題就走了。