Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8544969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:41:09+00:00 2026-06-11T12:41:09+00:00

I need help with using a normal SQL LIKE %% operator within a LINQ

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:41:10+00:00Added an answer on June 11, 2026 at 12:41 pm

    I figured it out using some of @Yaqub Ahmad code:

    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 _
                    System.Data.Linq.SqlClient.SqlMethods.Like(hl.Type, "%" & category & "%") _
                ) _
                Order By hl.Type Select hl).ToList()
    
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help writing a script downloads data from google insight using c# this is
We are using Linq-to-SQL with stored Procedures we need help on one of our
i need help with this. I'am using JQuery's Dynamic Form plug-in, it duplicates my
I really need help this time - Joomla 2.5 and latest K2. I'm using
I need to display a text like this on my PDF using iTextSharp Recommendation
I need help with using VQmod, if anyone has any experience with, I'd appreciate
I need some help using regex in java. Im trying to achieve 2 different
Possible Duplicate: Regular expression: match all words except I need your help for using
I need help reading the contents of a webpage. Currently i am using the
I need help in jquery. Thanks in advance. I am using autocomplete function of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.