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 9115631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:28:41+00:00 2026-06-17T04:28:41+00:00

Okay, this behavior has me really stumped. I have an IQueryable list that I’m

  • 0

Okay, this behavior has me really stumped. I have an IQueryable list that I’m trying to add Where clauses to check whether a string field contains a substring. When I hardcode the search string like this:

sourceList = sourceList.Where(license => license.FileNumber.Contains("S0"))

it works as expected and generates the internal query from inspecting sourceList in the Visual Studio debugger:

{SELECT [Extent1].[id] AS [id], [Extent1].[FileNumber] AS [FileNumber],
    [Extent1].[LegalLocation] AS [LegalLocation]FROM [dbo].[Licenses]
    AS [Extent1]WHERE [Extent1].[FileNumber] LIKE N'%S0%'}

The strange thing happens when I set the search value from a variable like:

string testString = "S0";
sourceList = sourceList.Where(license => license.FileNumber.Contains(testString))

This generates the internal query:

{SELECT [Extent1].[id] AS [id], [Extent1].[FileNumber] AS [FileNumber],
    [Extent1].[LegalLocation] AS [LegalLocation]FROM [dbo].[Licenses]
    AS [Extent1]WHERE [Extent1].[FileNumber] LIKE @p__linq__0 ESCAPE N'~'}

Notice the difference in the LIKE part at the end? I am really confused. Any help would be greatly appreciated. Here’s hoping it’s something really stupid. In case it has any relevance, this is for filtering data from an Entity Framework source.

Thanks,
Jason

  • 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-17T04:28:42+00:00Added an answer on June 17, 2026 at 4:28 am

    If you observe the actual query, you’ll see @p__linq__0 is actually assigned the S0 value, then passed to the query.

    @p__linq__0 = '%S0%';
    ... WHERE [Extent1].[FileNumber] LIKE @p__linq__0 ESCAPE N'~'
    

    Which basically is like:

    ... WHERE [Extent1].[FileNumber] LIKE N'%S0%' ESCAPE N'~'
    

    And because it’s a parameter, LINQ just takes the precaution and adds the ESCAPE clause. It’s also a variable instead of a hard-coded constant and any changing value in a LINQ statement is passed as a parameter instead of inserted directly in to the query.

    Reference: LIKE (Transact-SQL)

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

Sidebar

Related Questions

Okay so this one has some similar threads but I couldn't find anything that
Okay this question is very simple: I have a facebook page, and a website.
Okay this may be a simple question but I have yet to come with
Okay this is probably a really dumb question, however it's really starting to hurt.
Okay - this is the dumbest glitch I have seen in a while: <!DOCTYPE
Okay this is very hard to explain, but i want to add padding to
Okay so I have been trying to get into IoC lately. However, I keep
Okay, so we have a utility here in-house that generates business-model classes from our
I'm quite stumped on this issue. I have a large library of H.264 mp4
I have a nested hash table that looks like this: my %myhash = (

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.