Skip to content

V3 support for SQL Server input/output parameters #868

@mchallenjha

Description

@mchallenjha

Our project has a number of stored procs that declare an output parameter and pass a value in. The EF.Reverse.POCO.v3.ttinclude T4 template includes an enum StoredProcedureParameterMode { In, InOut, Out}, but InOut is not referenced. As a result, the application fails because the passed value is nullified when the procedure is called.

eg:

CREATE  PROCEDURE [config].[P_XXX]
    @groupId		INT OUTPUT, _-- a value is also passed in_
    @clientId		INT,
    @displayName	VARCHAR(30),

EF.Reverse.POCO.v3.ttinclude.txt

@description    VARCHAR(100),
@result			INT OUTPUT,
@failureReason	VARCHAR(4000) OUTPUT
AS

generated code:

public int P_XXX(out int? groupId, int? clientId, string displayName,
                 string description, out int? result, out string failureReason)
{
    var groupIdParam = new SqlParameter { ParameterName = "@groupId",
                 SqlDbType = SqlDbType.Int,
                 Direction = ParameterDirection.Output, 
                 Precision = 10,
                 Scale = 0 }; _// Direction should be InputOutput; missing Value = argument_

I modified the T4 (see attachment) to accommodate InputOutput parameters, which are now generated in code as "ref" instead of "out". This works, but I'd like to be able to override the stored proc parameter mode in my .tt file.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions