I'm coding a Multi-Search module that uses the following approach.
The query builds according to dropdown selections and associated checkboxes.
My question is how to make the JOIN query part compatible with the style of the more straightforward queries?
************************************
Public query(5) As String
.
.
Dim db As New myDataContext
Dim query As IQueryable(Of MainTable) = db.MainTables
.
.
If CheckBox1.Checked Then
query = query.Where(Function(u As MainTable) u.aaaID = dropdown_aaa.SelectedValue)
End If
If CheckBox2.Checked Then
query = query.Where(Function(u As MainTable) u.bbbID = dropdown_bbb.SelectedValue)
End If
If CheckBox3.Checked Then
' how to write this following bit in the same or compatible style as the others ????
query = From a In db.MainTables Join b In db.secondaryTable _
On a.ID Equals b.ID _
Where b.cccID = dropdown_ccc.SelectedValue
End If
.
.
result = query.Select(Function(u As MainTable) New With {u.ID, u.Surname, u.Town})
.
.
gv.DataSource = query
gv.DataBind()
Sorry about the complexity of my question but thanks in anticipation.