新しいオブジェクトクエリを作成するときに、TOPまたはSKIP機能の実装に問題があります。
「IN」コマンドを使用する必要があるため、eSQLを使用できません。INをループしてすべて「OR」パラメーターとして追加すると、非常に複雑になる可能性があります。
コードは以下の通りです:
Using dbcontext As New DB
Dim r As New ObjectQuery(Of recipient)("recipients", dbcontext)
r.Include("jobs")
r.Include("applications")
r = r.Where(Function(w) searchAppIds.Contains(w.job.application_id))
If Not statuses.Count = 0 Then
r = r.Where(Function(w) statuses.Contains(w.status))
End If
If Not dtFrom.DbSelectedDate Is Nothing Then
r = r.Where(Function(w) w.job.create_time >= dtDocFrom.DbSelectedDate)
End If
If Not dtTo.DbSelectedDate Is Nothing Then
r = r.Where(Function(w) w.job.create_time <= dtDocTo.DbSelectedDate)
End If
'a lot more IF conditions to add in additional predicates
grdResults.DataSource = r
grdResults.DataBind()
.Topまたは.Skipのいずれかの形式を使用すると、エラーがスローされます。LINQto Entitiesクエリでは、クエリビルダーメソッドはサポートされていません。
この方法を使用してTOPまたはLimitを指定する方法はありますか?可能であれば、1000件のレコードを返すクエリは避けたいと思います。(ユーザー検索画面用)