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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:54:06+00:00 2026-05-25T09:54:06+00:00

For those interested, I have now modified the SubSonic 2.x code to recognize and

  • 0

For those interested, I have now modified the SubSonic 2.x code to recognize and support DataTable parameter types.

You can read more about SQL Server 2008 features here: http://download.microsoft.com/download/4/9/0/4906f81b-eb1a-49c3-bb05-ff3bcbb5d5ae/SQL%20SERVER%202008-RDBMS/T-SQL%20Enhancements%20with%20SQL%20Server%202008%20-%20Praveen%20Srivatsav.pdf

What this enhancement will now allow you to do is to create a partial StoredProcedures.cs class, with a method that overrides the stored procedure wrapper method.

A bit about good form:
My DAL has no direct table access, and my DB only has execute permissions for that user to my sprocs. As such, SubSonic only generates the AllStructs and StoredProcedures classes.

The SPROC:

    ALTER PROCEDURE [dbo].[testInsertToTestTVP]
    @UserDetails TestTVP READONLY,
    @Result INT OUT
AS
BEGIN
    SET NOCOUNT ON;

    SET @Result = -1

    --SET IDENTITY_INSERT [dbo].[tbl_TestTVP] ON

    INSERT INTO [dbo].[tbl_TestTVP]
            ( [GroupInsertID], [FirstName], [LastName] )
    SELECT [GroupInsertID], [FirstName], [LastName]
    FROM @UserDetails

    IF @@ROWCOUNT > 0
        BEGIN
            SET @Result = 1
            SELECT @Result
            RETURN @Result
        END
    --SET IDENTITY_INSERT [dbo].[tbl_TestTVP] OFF

END

The TVP:

    CREATE TYPE [dbo].[TestTVP] AS TABLE(
    [GroupInsertID] [varchar](50) NOT NULL,
    [FirstName] [varchar](50) NOT NULL,
    [LastName] [varchar](50) NOT NULL
)
GO

The the auto gen tool runs, it creates the following erroneous method:

    /// <summary>
    /// Creates an object wrapper for the testInsertToTestTVP Procedure
    /// </summary>
    public static StoredProcedure TestInsertToTestTVP(string UserDetails, int? Result)
    {
        SubSonic.StoredProcedure sp = new SubSonic.StoredProcedure("testInsertToTestTVP", DataService.GetInstance("MyDAL"), "dbo");     
        sp.Command.AddParameter("@UserDetails", UserDetails, DbType.AnsiString, null, null);
        sp.Command.AddOutputParameter("@Result", DbType.Int32, 0, 10);            
        return sp;
    }

It sets UserDetails as type string.

As it’s good form to have two folders for a SubSonic DAL – Custom and Generated, I created a StoredProcedures.cs partial class in Custom that looks like this:

    /// <summary>
    /// Creates an object wrapper for the testInsertToTestTVP Procedure
    /// </summary>
    public static StoredProcedure TestInsertToTestTVP(DataTable dt, int? Result)
    {
        SubSonic.StoredProcedure sp = new SubSonic.StoredProcedure("testInsertToTestTVP", 
                                                                    DataService.GetInstance("MyDAL"), 
                                                                    "dbo");

        // TODO: Modify the SubSonic code base in sp.Command.AddParameter to accept
        //       a parameter type of System.Data.SqlDbType.Structured, as it currently only accepts
        //       System.Data.DbType.
        //sp.Command.AddParameter("@UserDetails", dt, System.Data.SqlDbType.Structured null, null);

        sp.Command.AddParameter("@UserDetails", dt, SqlDbType.Structured);
        sp.Command.AddOutputParameter("@Result", DbType.Int32, 0, 10);

        return sp;
    }

As you can see, the method signature now contains a DataTable, and with my modification to the SubSonic framework, this now works perfectly.

I’m wondering if the SubSonic guys can modify the auto-gen to recognize a TVP in a sproc signature, as to avoid having to re-write the wrapper?

Does SubSonic 3.x support Structured data types?

Also, I’m sure many will be interested in using this code, so where can I upload the new code?

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-25T09:54:07+00:00Added an answer on May 25, 2026 at 9:54 am

    I’ve posted a CodePlex project with the entire solution, source code and instructions.

    The project can be found here.

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

Sidebar

Related Questions

I have 2 lists each of equal size and am interested to combine these
For those who like a good WPF binding challenge: I have a nearly functional
For those of you who have implemented Scrum in your organizations, what were your
I have two divs stacked one above the other, with my code expanding the
I have always been interested in algorithms, sort, crypto, binary trees, data compression, memory
I have model created with visual designer. Now I want to have POCO classes
Right now I have a webpage set up to be exactly the size of
I have a situation where I have six possible situations which can relate to
Those of us with iPhone apps (released or unreleased) are able to send out
Those dark spinning progress dialogs in the Amazon and Engadget apps - are those

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.