Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting from temporary table #831

Closed
iahmed9312 opened this issue Jan 30, 2024 · 2 comments
Closed

Selecting from temporary table #831

iahmed9312 opened this issue Jan 30, 2024 · 2 comments
Assignees
Labels

Comments

@iahmed9312
Copy link

iahmed9312 commented Jan 30, 2024

Dear,

I am trying to select from a temporary table in a stored procedure, but in the generated code it is giving me "cannot be created due to having out parameters, or is relying on the procedure result (int)"

Here is an example stored procedure code:

CREATE PROCEDURE Test_SP2
AS
BEGIN
    SET NOCOUNT ON;
    SELECT 1 Col1 INTO #temp;
    SELECT Col1 FROM #temp;
END;

Regards,
Ahmed

@sjh37
Copy link
Owner

sjh37 commented Jan 30, 2024

This has been resolved and will be in the next release (tba). It now generates the following instead of the warning:

public int TestSp2()
{
    var procResultParam = new SqlParameter
    {
        ParameterName = "@procResult",
        SqlDbType = SqlDbType.Int,
        Direction = ParameterDirection.Output
    };

    Database.ExecuteSqlRaw("EXEC @procResult = [dbo].[Test_SP2] ", procResultParam);

    return (int)procResultParam.Value;
}

You can grab the latest code from here and overwrite your EF.Reverse.POCO.v3.ttinclude file with it.

Any problems, let me know

@sjh37 sjh37 closed this as completed Jan 30, 2024
@iahmed9312
Copy link
Author

The warning has gone now but it is not returning the result correctly, it is returning "int" instead of the result table.

What I am getting
Task<int> Test_SP2Async(CancellationToken cancellationToken = default(CancellationToken));

What i am expecting
Task<List<Test_SP2ReturnModel>> Test_SP2Async(CancellationToken cancellationToken = default(CancellationToken));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants