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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:20:47+00:00 2026-05-30T04:20:47+00:00

We have a new developer that is just now learning LinqToSql. While going over

  • 0

We have a new developer that is just now learning LinqToSql. While going over his code, we noticed that he was using .Equals instead of == for a value comparison. On top of that, he is comparing an int with a string. What completely baffled us, was that it worked!

After doing some testing it appears to only work with LinqToSql. Linq to objects returns false and just doing int.Equals(“string”) returns false.

Below is a simple test using two sql tables:

Customer
    Id(PK)(int)
    Name(varchar)
    CompanyId(FK)(int)


Company
    Id(PK)(int)
    Name(varchar)
Console.WriteLine("{0}.Equals(\"{1}\") returns {2}", 3, "3", 3.Equals("3"));
        using (WrDataClassesDataContext wrDataContext = new WrDataClassesDataContext())
        {
            var customers1 = from c in wrDataContext.Customers
                            where c.CompanyId.Equals("3")
                            select c;

            Console.WriteLine("int .Equals String Results: ");
            foreach (Customer customer in customers1)
            {
                Console.WriteLine(customer.Name);
            }

            var customers3 = from c in wrDataContext.Customers
                        where c.CompanyId == 3
                        select c;

            Console.WriteLine("int == int Results: ");
            foreach (Customer customer in customers3)
            {
                Console.WriteLine(customer.Name);
            }
        }

RESULTS:

3.Equals("3") returns False
int .Equals String Results:
Mike
Joe
Candy
int == int Results:
Mike
Joe
Candy
Press any key to continue . . .

Any explanation?

  • 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-30T04:20:49+00:00Added an answer on May 30, 2026 at 4:20 am

    LINQ to SQL generates SQL code from your LINQ query. In SQL, a comparison of an int to a string is perfectly valid. What happens is that by using .Equals, you bypass the type checking the == operator does at compile-time.

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

Sidebar

Related Questions

I am basically a windows developer and very new to Sharepoint. I have Designed
Right now I have a few new applications being developed against an Oracle Database,
I have noticed some developers picking up new skills and moving from one platform
I have an application that has been running fine since its launch over a
I am a brand new Java developer (I have been working in asp.net) and
Unfortunately I inherited some code (c/c++) that does some string manipulation and now I
I have an appliction right now that is a pipeline design. In one the
I've just started working for a new firm as an in-house web developer. Up
Heres my problem, I'm web developer and I have a web based script(PHP/CURL/HTML/JS) that
I encountered an interesting thing today that I have never noticed before. It appears

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.