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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:49:53+00:00 2026-05-19T10:49:53+00:00

I have a question for the TSQL experts out there or the LINQ C#

  • 0

I have a question for the TSQL experts out there or the LINQ C# experts out there. I have a stored procedure that joins in a few tables. Basically Name, ID, and about 10 product columns. The stored procedure can return a lot of data (90,000+ rows sometimes). In the stored proc I filter the results to filter out all rows where all of the products in that row = 0. What I need to do is to remove columns in C# where all of the values in a column (product) are zero. This is due to some business rules within my application (customer request).

The application can remove (hide) columns by sending an array of the column names to a report builder. For example:

|Name|ID|Prod1|Prod2|Prod3|Prod4|

If I wanted to remove Prod3 and Prod4 from the report:

List<string> hideColumns = new List<string>();
hideColumns.Add("Prod3");
hideColumns.Add("Prod4");

and I would send
hideColumns.ToArray()
to the report builder and those columns would be removed.

In my application I send in all of the data, then use the following LINQ to find the column values for the returned data.

var zeroCols = from result in data
               group result by new { } into C
               select new ProductDataClass
               {
                   Prod1 = C.Sum(x => x.Prod1)
                   Prod2 = C.Sum(x => x.Prod2)
                   ...etc to Prod10
               };

To find which is 0

if (zeroCols.Count() > 0)
{
    if (zeroCols.First().Prod1 == 0)
        hideColumns.Add("Prod1");
    ...etc to Prod10
}

However, my problem is that the LINQ is really slow if the report returns a lot of rows. Can anybody make any suggestions?

  • 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-19T10:49:53+00:00Added an answer on May 19, 2026 at 10:49 am

    It would be faster to split this into two queries- one to return the data, and another aggregate query to return a single row. The return from the aggregate query can be used to determine which columns are 0 and should be hidden.

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

Sidebar

Related Questions

I have a simple question regarding T-SQL. I have a stored procedure which calls
I have a ADO.NET/TSQL performance question. We have two options in our application: 1)
I have a question regarding locking in TSQL. Suppose I have a the following
Scenario I have a stored procedure written in T-Sql using SQL Server 2005. SEL_ValuesByAssetName
I've a question for you. We have built a software that has a single
I have a question about TSQL function Update. For example, I have a table
I have two tables (well, two relevant for this question) : Bets (holds the
I basically need the answer to this SO question that provides a power-law distribution
I have ' inherited ' a brilliant piece of TSQL code that does this:
I have an ETL process that is, for this question's purpose, done entirely 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.