Dixin / EntityFramework.Functions

EntityFramework.Functions library implements Entity Framework code first support for stored procedures (with single result type, multiple result types, output parameter), table-valued functions (returning entity type, complex type), scalar-valued functions (composable, non-composable), aggregate functions, built-in functions, niladic functions, and model defined functions.
https://weblogs.asp.net/Dixin/EntityFramework.Functions
MIT License
79 stars 27 forks source link

mixing output params and input params on stored proc does not seem to work, but when changed to both output, it does work #39

Open westpicoblvd opened 4 years ago

westpicoblvd commented 4 years ago

If I'm mapping a stored proc with one output param and one input param, exceptions are thrown 👍 SqlException: The formal parameter "@QueueId" was not declared as an OUTPUT parameter, but the actual parameter passed in requested output.

Please advise, it does not matter what order I change the args to stored proc, but when they are both output, it works.

SqlException: The formal parameter "@QueueId" was not declared as an OUTPUT parameter, but the actual parameter passed in requested output.

SQL:

**alter procedure [TM].[TaskInputZombie5] ( @Message nvarchar(400) output,@QueueId int

) as begin declare @ierr int = 10 select @QueueId = @ierr * @ierr

set @Message = @Message + 'more: ' + CONVERT(nvarchar(40),@QueueId)
return 0 end** c#:

    public int TaskInputZombie5(
        [Parameter(DbType = "int", ClrType = typeof(int), Name = "QueueId")] ObjectParameter QueueId,
        [Parameter(DbType = "nvarchar", ClrType = typeof(string), Name = "Message")] ObjectParameter Message)
    {

        ObjectParameter[] paramsObjectParameter = new ObjectParameter[2];
        paramsObjectParameter[0] = Message;
        paramsObjectParameter[1] = QueueId;
        return this.ObjectContext().ExecuteFunction(nameof(this.TaskInputZombie5),
            paramsObjectParameter);
    }