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

  • SEARCH
  • Home
  • 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 7434245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:48:16+00:00 2026-05-29T09:48:16+00:00

I need to OR two SqlMethods.Like statements in LINQ, and I’m not sure how

  • 0

I need to OR two SqlMethods.Like statements in LINQ, and I’m not sure how to accomplish it (or if it’s the right way to go about it).

I’ve got vendor ID and vendor name fields, but I’ve only got a generic vendor search that allows a user to search for a vendor based on their name or ID. I also allow wildcards in the search, so I need to find vendors whose ID or name is like the user’s input.

I want to do something like below, but obviously it’s not correct. (EDIT: It does work as written.)

results = results.Where(p => SqlMethods.Like(p.VendorId, inputVendor.Replace("*", "%") ||
                             SqlMethods.Like(p.VendorName, inputVendor.Replace("*", "%"));

Background: I add where statements depending on the search parameters entered by the user, hence the results = results.Where part.

Any help would be appreciated!

  • 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-05-29T09:48:17+00:00Added an answer on May 29, 2026 at 9:48 am

    It’s not clear to me why this is “obviously” not correct. Presumably it’s not working, otherwise you wouldn’t have posted, but it’s not obvious how it’s not working.

    I would suggest performing the replacement before the query, like this:

    string vendorPattern = inputVendor.Replace("*", "%");
    

    But then I’d expect this to work:

    results = results.Where(p => SqlMethods.Like(p.VendorId, vendorPattern) ||
                                 SqlMethods.Like(p.VendorName, vendorPattern));
    

    Of course you’re limited to where wildcards can appear in a SQL LIKE query, but that’s a separate problem. (I’m not sure of the behaviour offhand if it’s not at the start or end.)

    If that doesn’t help, please update the question with what happens when you try this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need two divs to look a bit like this: | | ---| LOGO
I need two tables and two sets of fields, not the name of the
I need two divs side by side with the one on the right always
I need two divs to look a bit like this: | | ---| DIV
I need two things that the Membership Provider I'm sure is capable of doing.
I need two methods one to encrypt and one to decrypt an xml file
Why do I need two of them? When I have to use one or
I have a form that has a group of 3 text_fields. I need two
I need UNION two tables with creating new field, where 1 for first table,
Basically, why the need for two abstractions of a pretty simple concept?

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.