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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:42:22+00:00 2026-05-11T11:42:22+00:00

I have a general question, and curiosity about LINQ and timeouts. I have a

  • 0

I have a general question, and curiosity about LINQ and timeouts.

I have a live application running and I am receiving timeouts on the following code.

The following code, which is normal, and I don’t see anything wrong:

private static tblUser GetUserLinq(string email, string password) { DataContext db = new DataContext();

        var tblUsers = from user in db.tblUsers                            where user.EmailAddress == email                            && user.Password == password                            select user;          if (tblUsers.Count() == 0)             return null;          return tblUsers.First();     } 

But getting the following timeouts, quite a few, on:

        if (tblUsers.Count() == 0) 

Here is the Exception

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. – System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult) at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) at System.Data.Linq.DataQuery1.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.Count[TSource](IQueryable1 source) at Actions.GetUserLinq(String email, String password) in C:\Actions.cs:line 104 at Login(String email, String password) in C:\Actions.cs:line 33

Some of my thoughts on why it is timing out:

The count needs to count the number of records in that table, and that is not what we are after If we are trying to find if a record exists then should we be using the following code:

        var tblUsers = (from user in db.tblUsers                            where user.EmailAddress == email                            && user.Password == password                            select user).FirstOrDefault(u => u.UserId <0) ; 

Otherwise I am a little confused to why LINQ is timing out on a Count

One other thing I have noticed is that if you run the following SQL directly on the machine through SQL Enterprise Manager, it also times out, which suggests that it is perhaps a locking issue, however the only application calling this table is LINQ

select count(userid) from tbluser

Comments most welcome

  • 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. 2026-05-11T11:42:22+00:00Added an answer on May 11, 2026 at 11:42 am

    You should check your user table’s indexes. It might be that a username/password index helps.

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

Sidebar

Related Questions

I have a general question about jQuery. Lets say I have the following code:
I have a general question about the interaction of linq with an entityquery and
Hi I have a general question about Lists in C#. Here is my Code:
I have a general question on the class definition and its use..THe below code
I have a general question about interpreters of functional languages: Are there actually any
i have a general question : i'd like to develop a facebook application using
I have a general question about the new Django 1.3 static file framework. I
I have a general question that is rather open-ended (i.e. depends on platform, application
I have a general question for the group. I am about to start a
I have a general question about the way that database indexing works, particularly in

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.