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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:38:17+00:00 2026-05-23T04:38:17+00:00

Relational Database: Sql Server 2008 Programming Language: C# Used Framework: Enterprise Library 5.0 How

  • 0

Relational Database: Sql Server 2008
Programming Language: C#
Used Framework: Enterprise Library 5.0

How do you access output parameters that are created within the implementation of IParameterMapper?

I’m currently implementing the Repository Pattern. All of our Insert stored procedures contain an output parameter. The output parameter is only present in for those tables who’s primary key is an auto generated identity column. All of my stored procedures have associated implementations of IParameterMapper. Each table has an associated TransferObject. Each TransferObject has an associated IRowMapper implementation.

If it is impossible to access the output parameter I believe I only have two other options.

1) Change the stored procedures to return a row that contains the newly created identity as opposed to returning the value through an output parameter. By doing it this way I can use the currently implemented IRowMapper to access the value in the application layer. This way would be more resource intensive but less programming will be needed within the repository.

2) Don’t use Database.ExecuteSprocAccessor and just execute the stored procedure “normally”; keeping the stored procedures as they are. This would be the most efficient solution, but require more programming effort.

Below is an example of how we are currently implementing things.

Current Implementation

public class UserRepository : IRepository<User>
{
    ....
    public void Insert(User user)
    {
        this.database.
    }
    ....
}

public class User : TransferObject
{
    public string ID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

public class UserRowMapper : IRowMapper<User>
{
    private static readonly UserRowMapper instance = new UserRowMapper();

    private UserRowMapper()
    {
    }

    public UserRowMapper Instance
    {
        get
        {
            return instance;
        }
    }

    public User MapRow(IDataRecord row)
    {
        var user = new User
            {
                ID = row.GetInt32("ID"),
                FirstName = row.GetString("FirstName"),
                LastName = row.GetString("LastName")
            };
    }
}

public class InsertUserParameterMapper : IParameterMapper
{
    private static readonly InsertUserParameterMapper instance = new InsertUserParameterMapper();

    public InsertUserParameterMapper()
    {
    }

    public static InsertUserParameterMapper Instance
    {
        get
        {
            return instance;
        }
    }

    public void AssignParameters(DBCommand command, object[] parameterValues)
    {
        var firstNameParameter = command.CreateParameter();
        firstNameParameter.ParameterName = "@firstName";
        firstNameParameter.Direction = ParameterDirection.Input;
        parameter.Value = parameterValues[0];
        command.Parameters.Add(firstNameParameter);

        var lastNameParameter = command.CreateParameter();
        lastNameParameter.ParameterName = "@lastName";
        lastNameParameter.Direction = ParameterDirection.Input;
        parameter.Value = parameterValues[1];
        command.Parameters.Add(lastNameParameter);

        var idParameter = command.CreateParameter();
        idParameter.ParameterName = "@id";
        idParameter.Direction = ParameterDirection.Output;
        command.Parameters.Add(idParameter);

    }
}
  • 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-23T04:38:18+00:00Added an answer on May 23, 2026 at 4:38 am

    Output parameters were explicitly not included in the accessor design. If your sproc uses them, you’re much better off calling the sproc directly.

    Considering you’re using this with an insert sproc, I suspect it’s not returning rows anyway, so the accessor is really not the right abstraction. You want a straight sproc call.

    Having said that, you can still use your input mapper if you want – it doesn’t have any particular dependency on an accessor, you could call it directly, passing a DbCommand object instead. But db.ExecuteNonQuery does effectively what you’re doing already anyway, so you might just get shorter code out of the deal.

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

Sidebar

Related Questions

I heard that decision tables in relational database have been researched a lot in
In a C++ application that can use just about any relational database, what would
I'm not clear about the security-related catalog views in SQL Server 2005 or 2008.
I'm thinking about how to represent a complex structure in a SQL Server database.
Does anyone have any good scenarios for teaching relational databases and SQL? All the
When would you use a bigtabe/simpledb database vs a Relational database?
I'm looking for a book/site/tutorial on best practices for relational database design, tuning for
All of us who work with relational databases have learned (or are learning) that
I need to develop a small Flex application that needs to access a MySQL
Flat files and relational databases give us a mechanism to serialize structured data. XML

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.