I need help with using a normal SQL LIKE %% operator within a LINQ query.
This is the data for row called Type (thats returned from the normal query without the like operator):
Independent Contractor
Lease Program
Teams
Teams interested
And this is my (attempted) LINQ query:
Public Shared Function SelectActiveByState(
ByVal state_abbr As String,
ByVal catagory As String) As List(Of theLocations)
Dim db As New MasterData
db.CommandTimeout = 240
Try
Return ( _
From hl In db.Locations _
Where hl.Active = True _
And ( _
hl.State = state_abbr Or _
hl.AlternateLocation.Contains(state_abbr) And _
hl.Type.Contains("/" & catagory & "/") _
) _
Order By hl.Type Select hl).ToList()
Catch ex As Exception
Return Nothing
End Try
End Function
If i leave out the And hl.Type.Contains(“/” & catagory & “/”) the query works just fine (returns 4 records). But when i add that part it returns the same records regardless of my like operator.
I figured it out using some of @Yaqub Ahmad code: