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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:41:56+00:00 2026-05-14T22:41:56+00:00

I am checking login of a user by this repository method, public bool getLoginStatus(string

  • 0

I am checking login of a user by this repository method,

  public bool getLoginStatus(string emailId, string password)
    {
        var query = from r in taxidb.Registrations
                    where (r.EmailId == emailId && r.Password==password)
                    select r;
        if (query.Count() != 0)
        {
            return true;
        }
        return false;
    }

I saw in one of the previous questions !query.Any() would be faster… Which should i use? Any suggestion….

  • 1 1 Answer
  • 1 View
  • 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-14T22:41:56+00:00Added an answer on May 14, 2026 at 10:41 pm

    The sql generated will be different between the two calls. You can check by setting your context.Log property to Console.Out or something.

    Here’s what it will be:

    SELECT COUNT(*) AS [value]
    FROM [dbo].[Registrations] AS [t0]
    WHERE [t0].[EmailId] = @p0 and [t0].Password = @p1
    
    SELECT 
        (CASE 
            WHEN EXISTS(
                SELECT NULL AS [EMPTY]
                FROM [dbo].[Registrations] AS [t0]
                WHERE [t0].[EmailId] = @p0 and [t0].Password = @p1
                ) THEN 1
            ELSE 0
         END) AS [value]
    

    In this case, I doubt it will make any difference because EmailID is probably a unique index so there can only be 1 result. In another case where count can be > 1, Any would be preferable because the second query allows sql server to short circuit the search since it only needs to find one to prove that any exist.

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

Sidebar

Related Questions

I am just checking out F#, so apologies if this is a silly question,
Checking the HTML source of a question I see for instance: <a id=comments-link-xxxxx class=comments-link>add
I was checking out Intel's whatif site and their Transactional Memory compiler (each thread
I'm checking for existing of a row in in_fmd, and the ISBN I look
I'm checking out the Delphi 2009 Trial, but run into problems with the generics
I was checking Microsoft's Visual Studio page just now and in the advertisements sidebar
The code below is checking performance of three different ways to do same solution.
I'm checking if two strings a and b are permutations of each other, and
Is type checking considered bad practice even if you are checking against an interface?
Is there a way to enforce constraint checking in MSSQL only when inserting new

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.