.net ActiveRecord Linq/NHibernate Linq未完全生成查询
鉴于此功能:.net ActiveRecord Linq/NHibernate Linq未完全生成查询,.net,vb.net,linq,nhibernate,castle-activerecord,.net,Vb.net,Linq,Nhibernate,Castle Activerecord,鉴于此功能: 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, _ B
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()
我试图根据传入函数的参数一次构建一个where子句,如下所示:
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
。。。其他参数的更多if语句
_log.Debug("Start Count query")
count = remits.Count()
_log.Debug("End Count query")
使用lastname=“smith”调用此函数,当我到达count=relimes.count()
行时,观察SQL事件探查器,它生成如下SQL(与nhibernate生成的SQL相关联):
而不是我所期望的:
Select count(*) from remitline where lastname = "smith"
我在构建where子句时做错了什么?我正在使用Castle ActiveRecord 2.1
TIA更新到最新版本的ActiveRecord(3.0 RC),这个问题就消失了
Select count(*) from remitline where lastname = "smith"