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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:18:44+00:00 2026-05-19T11:18:44+00:00

Yeah, yet another nhibernate & stored procedures question, sorry… I have two stored procedures

  • 0

Yeah, yet another nhibernate & stored procedures question, sorry…

I have two stored procedures which return the same structure (so I would like to bind them to the same class), the only difference is the ‘where’ condition in the second stored procedure. Can I bind both stored procedures to my class? How would the mapping file look like? Or would you prefer different approaches:

  • use only one stored procedure and add new input parameter which says how the procedure should behave
  • don’t use NHibernate at all – use DataAdapter instead
  • create a view (but in my example I don’t know how…)
  • …

First stored procedure:

ALTER procedure [BadCodes].[GetCodesBetween]
    @codeFrom bigint,
    @codeTo bigint
as
begin
    set nocount on

    ;with BadCodesOriginal as (
        select Code 
        from Scanning.BadCodes 
        where Code between @codeFrom and @codeTo
    ),
    BadCodesScanned as (
        select Code, count(*) NumberOfBadCodesScanned 
        from BadCodes.Scan
        where Code between @codeFrom and @codeTo
        group by Code
    )
    select t1.Code Code, isnull(t2.NumberOfBadCodesScanned, 0) NumberOfBadCodesScanned
    from BadCodesOriginal t1 left join BadCodesScanned t2 on (t1.Code = t2.Code)
    order by t1.Code
end

Second stored procedure:

ALTER procedure [BadCodes].[GetCodesBetweenDifference]
    @codeFrom bigint,
    @codeTo bigint
as
begin
    set nocount on

    ;with BadCodesOriginal as (
        select Code 
        from Scanning.BadCodes 
        where Code between @codeFrom and @codeTo
    ),
    BadCodesScanned as (
        select Code, count(*) NumberOfBadCodesScanned 
        from BadCodes.Scan
        where Code between @codeFrom and @codeTo
        group by Code
    )
    select t1.Code Code, isnull(t2.NumberOfBadCodesScanned, 0) NumberOfBadCodesScanned
    from BadCodesOriginal t1 left join BadCodesScanned t2 on (t1.Code = t2.Code)
    where isnull(t2.NumberOfBadCodesScanned, 0) <> 1
    order by t1.Code
end

And this is my class:

public class CheckedBadCodeOverview
    {
        public virtual long Number { get; set; }
        public virtual int NumberOfScans { get; set; }

        public CheckedBadCodeOverview()
        {
        }
    }
  • 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-19T11:18:45+00:00Added an answer on May 19, 2026 at 11:18 am

    Just add a <sql-query> for each SP.

    Check 16.2.2. Using stored procedures for querying

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

Sidebar

Related Questions

Yeah, the noob question of the century... But in all seriousness, I actually have
my question is probably identical and have same motive as this here i ain't
Hello yeah I'm asking this question a second time, sorry about that but I
My code works (yeah!) which sends json to a server.. would appreciate any thoughts
I have a ListBox with horizontal scrolling, and each item consists of a two
Ok, I have code like this: <div id=header> (yeah, have to use div instead
Yeah, yeah, I know, strict mode ain't around yet, but really, I'm planning for
I have this Dispose method I want to change. (Yeah I should check every
I have an iframe with designMode=on (Yeah - I know this is bad thing)
Before you say, yeah this question can be duplicate; https://stackoverflow.com/questions/2912890/gridview-freeze-pane-solutions How to freeze GridView

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.