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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:28:18+00:00 2026-05-16T04:28:18+00:00

Hi am using ISingleResult with an Stored procedure. How do i check in C#

  • 0

Hi am using ISingleResult with an Stored procedure.
How do i check in C# if the Isingler is empty or not. Because sometime the SP returns nothing and sometime is returns data.

Is there anyway to se how many rows the ISingleResult contains.
Thanks for help.

  • 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-16T04:28:18+00:00Added an answer on May 16, 2026 at 4:28 am

    You can convert the result to a list (using the LINQ ToList method) or to an array (with ToArray), and then check the count/length from there.

    List<T> result = YourStoredProcedureCall().ToList();
    
    if (result.Count > 0) 
    {
        // Deal with results here
    }
    

    As mentioned by Cullen’s answer, you can get the number of returned results by using the Count() method. Please note that this will internally iterate through the list to calculate the count, which is not optimal if you’re just trying to determine if you have 1 or more results.

    NOTE:

    For any of these, please be sure that you have the following using statement in your source file:

    using System.Linq;
    

    EDIT NOTE:

    I had originally suggested using the Any() method directly on the ISingleResult result, but this will most likely result in an exception saying ‘The query results cannot be enumerated more than once.’ if you then try to enumerate the ISingleResult again. Converting into an array or list first avoids this exception. From there, you can still use Any() on the array/list, or you can evaluate the Count or Length property directly as shown in the code example.

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

Sidebar

Related Questions

using select statement we can call functions inside the stored procedure, is there another
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using Linq to call a stored procedure that passes a single string, The stored
I'm using visual studio 2008 and I've created a stored procedure that selects back
I have a stored procedure that returns a result set (4 columns x n
Using asp.net MVC in c#, I am making a call to a stored procedure
I need to run a stored procedure on SQL Server, using LINQ, and throw
I have a stored procedure in a SQL Server database that returns a list
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using TortoiseSVN against VisualSVN I delete a source file that I should not have

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.