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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:29:33+00:00 2026-05-22T23:29:33+00:00

I have a data caller method that returns a SubSonic collection of type ItemDatumCollection.

  • 0

I have a data caller method that returns a SubSonic collection of type ItemDatumCollection.

The sproc is executed as follows:

itemDatumCollection.LoadAndCloseReader(sp.GetReader());

However, I am unable to access the output parameters of the sproc in this fashion, as I am able to do when calling sp.GetDataSet() as follows:

            itemsDataSet = sp.GetDataSet();

            actualNumberOfResults = ((Int64)sp.OutputValues[1]);
            numberOfResultsReturned = ((Int64)sp.OutputValues[2]);

Is there a way to access the sproc’s output parameters with the first method – returning a SubSonic strongly-typed collection from my sproc call?

Thanks.

  • 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-22T23:29:34+00:00Added an answer on May 22, 2026 at 11:29 pm

    I wanted to do something similar, and ended up changing most of the StoredProcedures.tt file, and I think some of the internals of SubSonic. Without getting too into detail, I changed by .tt file so that it would generate this for a given stored proc:

        public void COMPANIES_ACTIVATE_PACKAGE(long PI_COMPANY_ID, string PI_ACTIVE, long PI_USER_ID, out long PO_ERRCODE, out string PO_ERRMSG, out string PO_ORA_ERRMSG){
            StoredProcedure sp=new StoredProcedure("COMPANIES.ACTIVATE_PACKAGE",this.Provider);
            sp.Command.AddParameter("PI_COMPANY_ID",PI_COMPANY_ID,DbType.Decimal);
            sp.Command.AddParameter("PI_ACTIVE",PI_ACTIVE,DbType.AnsiString);
            sp.Command.AddParameter("PI_USER_ID",PI_USER_ID,DbType.Decimal);
            sp.Command.AddOutputParameter("PO_ERRCODE",DbType.AnsiString);
            sp.Command.AddOutputParameter("PO_ERRMSG",DbType.AnsiString);
            sp.Command.AddOutputParameter("PO_ORA_ERRMSG",DbType.AnsiString);
            sp.Execute();
            var prms = sp.Command.Parameters;
            PO_ERRCODE = ConvertValue<long>(prms.GetParameter("PO_ERRCODE").ParameterValue);
            PO_ERRMSG = ConvertValue<string>(prms.GetParameter("PO_ERRMSG").ParameterValue);
            PO_ORA_ERRMSG = ConvertValue<string>(prms.GetParameter("PO_ORA_ERRMSG").ParameterValue);
        }
    

    So basically I pass in any sproc parameters, and have ‘out’ parameters defined for the return values.

    Also not shown here, but if I have an InOut parameter, then I pass it by ref instead of out.

    Then in my actual application code, I can just call the stored proc like any other function:

    long errorCode;
    string errorMsg, oraErrorMsg;
    
    db.COMPANIES_ACTIVATE_PACKAGE(123, "Y", 456, out errorCode, out errorMsg, out oraErrorMsg);
    
    if(errorCode > 0)
        // ... handle error...
    

    I don’t know if this will plug right in to SS without further changes, but this is my .tt file. You might be able to use it, or at least get some ideas of where to go:

    StoredProcedures.tt :

    <#@ template language="C#" debug="False" hostspecific="True"  #>
    <#@ output extension=".cs" #>
    <#@ include file="DB2DataProvider.ttinclude" #>
    <#
        var sps = GetSPs(); 
        if(sps.Count>0){ 
    #>  
    using System;
    using System.Data;
    using System.ComponentModel;
    using SubSonic;
    using SubSonic.Schema;
    using SubSonic.DataProviders;
    
    namespace <#=Namespace#>{
        public partial class <#=DatabaseName#>DB{
    
            public T ConvertValue<T>(object paramVal)
            {
                if (paramVal == null || Convert.IsDBNull(paramVal))  // if the value is null, return the default for the desired type.
                    return default(T);
                if (typeof(T) == paramVal.GetType())  // if types are already equal, no conversion needed. just cast.
                    return (T)paramVal;
                else // types don't match. try to convert.
                {
                    var conversionType = typeof(T);
                    if (conversionType.IsGenericType && conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
                    {
                        NullableConverter nullableConverter = new NullableConverter(conversionType);
                        conversionType = nullableConverter.UnderlyingType;
                    }
                    return (T)Convert.ChangeType(paramVal, conversionType);
                }
            }
    
    <#  foreach(var sp in sps){#>
            public void <#=sp.CleanName#>(<#=sp.ArgList#>){
                StoredProcedure sp=new StoredProcedure("<#=sp.Name#>",this.Provider);
    <#      foreach(var par in sp.Parameters) {
              if(par.In && !par.Out) {#>
                sp.Command.AddParameter("<#=par.Name#>",<#=par.CleanName#>,DbType.<#=par.DbType#>);
    <#        } else if(!par.In && par.Out) {#>
                sp.Command.AddOutputParameter("<#=par.Name#>",DbType.<#=par.DbType#>);
    <#        } else {#>
                sp.Command.AddParameter("<#=par.Name#>",<#=par.CleanName#>,DbType.<#=par.DbType#>,ParameterDirection.InputOutput);
    <#      }}#>
                sp.Execute();
    <#      bool hasOut = false;
            foreach(var par in sp.Parameters) {
              if(par.Out)
                hasOut = true;
            }
            if(hasOut) {
    #>
                var prms = sp.Command.Parameters;
    <#      }
            foreach(var par in sp.Parameters) {
              if(par.Out) {#>
                <#=par.Name#> = ConvertValue<<#=par.SysType#>>(prms.GetParameter("<#=par.Name#>").ParameterValue);
    <#      }}#>
            }
    <#  }#>
    
        }
    
    }
    <#  }#>
    

    I’m pretty sure I also had to change the query that loads stored proc data in the database provider .ttinclude file to load the column that indicates if it is In, Out, or InOut parameter type.

    …Hope this helps in some way…

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

Sidebar

Related Questions

I have a data tier select method that returns a datatable. It's called from
I have data that needs to be executed on a certain background thread. I
I have created a method in my data context that is mapped to a
I have an ASP.NET webservice method that returns a generics list (List'<'Construct>) serialized as
Let's say I have a class that has a member called data which is
I have data that looks like CUSTOMER, CUSTOMER_ID, PRODUCT ABC INC 1 XYX ABC
I have data from a table in a database (string) that contain text and
I have data that looks like this: entities id name 1 Apple 2 Orange
I have a strange, sporadic issue. I have stored procedure that returns back 5
I have an asp.net WebMethod that returns an XmlDocument object. I can successfully call

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.