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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:10:40+00:00 2026-06-10T20:10:40+00:00

I just discovered some strange behaviour running a query in LinqPad. It seems that

  • 0

I just discovered some strange behaviour running a query in LinqPad. It seems that some ASCII symbols/characters are considered equal by LinqToSQL when they actually are not.

Consider the following class (with a corresponding table):

public class SpecialCharacter
{
    int Id;
    string Character;
    string Name;
}

If you add a row to your table for “⇒”(right arrow) and “⇐” (left arrow) the following query will tell you they are equal (result will contain two items):

var result = from a in SpecialCharacters
             from b in SpecialCharacters
             where a.Character == b.Character  && a != b
             select new {A = a, B = b};

Changing the query by adding a call to .ToList() will result in the expected behaviour (result is empty):

var result = from a in SpecialCharacters.ToList()
             from b in SpecialCharacters.ToList()
             where a.Character == b.Character && a != b
             select new {A = a, B = b};

Any ideas how this comes about?

  • 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-10T20:10:41+00:00Added an answer on June 10, 2026 at 8:10 pm

    The difference you are seeing is due to differences between how LINQ handles equality and SQL server’s collation settings. You would see the same thing if you did a case sensitive search. LINQ to Objects. Consider the following query:

    var query = from c in Customers
                where c.City == "london"
                select c;
    

    LINQ to Objects would match cities that are london, but not London or LONDON. LINQ to SQL or EF on the other hand would default to matching any of those three because it is case insensitive. You may want to check the generated TSQL in LINQ to SQL by inspecting the result.ToString to see the SQL generated and then run that SQL directly in SSMS. You should see the same extra records returned. You will probably need to tweak the collation settings or other database specific settings to get the correct behavior on this query.

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

Sidebar

Related Questions

I just discovered when creating some CRUD tests that you can't set data in
I just discovered that the caps lock and shift key (and probably some more
I just discovered that some programs are very quick when getting/listing the directory of
I just discovered that some parts of the code I am working on incorrectly
I'm having some trouble. I just discovered that you can control vimeo with js,
A friend of mine discovered some strange behaviour with NSDictionary, and I'm curious as
I've just discovered (by necessity) that TSQL has some functionality to extract data from
I just discovered that %ws was common knowledge (to some), for formatting unicode strings,
I just discovered that truncate {table} statements are not caught by most database triggers.
i just discovered http://code.google.com/p/re2 , a promising library that uses a long-neglected way (

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.