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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:59:46+00:00 2026-05-17T20:59:46+00:00

I have a stored proc that returns a resultset thus: testID(guid), testName, outcomeID(guid), outcomeName

  • 0

I have a stored proc that returns a resultset thus:

testID(guid), testName, outcomeID(guid), outcomeName – fields

testGuid1, testName1, OutcomeGuid1, outcome1

testGuid1, testName1, OutcomeGuid2, outcome2

testGuid1, testName1, OutcomeGuid3, outcome3

testGuid1, testName1, OutcomeGuid4, outcome4

testGuid1, testName1, OutcomeGuid5, outcome5

testGuid2, testName2, OutcomeGuid9, outcome9

testGuid2, testName2, OutcomeGuid1, outcome1

testGuid2, testName2, OutcomeGuid3, outcome3

etc.
so basically there are a number of tests which each have a number of outcomes, some of the outcomes will be common across the tests

what i would like to do is get a MAX count of outcomes across all tests, i would like to do this with some sort of lambda linq type thing.
so for the above results i am looking for the number 5

if i do :

var Results = dc.getTests(id); 
//need the whole resultsset for binding to something in a mo.
//then would like to do somethign along the lines of:
int count = Results.GroupBy(t=>t.testID).count(*).Max() //or something?

if i debug i get (removing the count part of the above line) a IGrouping Linq thing which does have a non public count property, but i cant seem to get to it.
i expect there is a better way of getting this number anyway. could someone enlighten me please

many thanks

nat

  • 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-17T20:59:47+00:00Added an answer on May 17, 2026 at 8:59 pm
    var max = Results.GroupBy(t=>t.testID).Max(grp => grp.Count());
    

    However, note that personally I’d be looking for a way to do this at the DB, rather than fetching all that data over the network just to get a single number. A good option would be to push the code into a UDF, and change the SP so simply SELECT * FROM dbo.YourUdf(args) – the reason being that UDFs are composable, so you could map the UDF into the data-context and have:

    var max = db.MyUdf(args).GroupBy(t=>t.testID).Max(grp => grp.Count());
    

    (i.e. the same code), and it would do the work at the server, just bringing back a single number over the network.

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

Sidebar

Related Questions

I have a stored proc with the basic layout below that returns a sys_refcursor
I have a stored proc that returns 4 rows in a table. Each row
I have a stored proc on sql server 2008 that excepts a int parameter.
I have a WCF service method that calls a SQL stored proc. I'm developing
I have a Stored proc which returns 6 select statement results. I'm trying to
I have a stored proc which unions some data and returns back. At max
I have a VB.Net function which executes a Oracle Stored Proc and returns a
I have a stored proc on SQL Server 2000 that takes 3 parameters. When
I have a stored proc that is called from my asp.net page. The field
i have a stored proc A that contains a stored proc B. stored proc

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.