sjh37 / EntityFramework-Reverse-POCO-Code-First-Generator

EntityFramework Reverse POCO Code First Generator - Beautifully generated code that is fully customisable. This generator creates code as if you reverse engineered a database and lovingly created the code by hand. It is free to academics (you need a .edu or a .ac email address), not free for commercial use. Obtain your licence from
https://www.reversepoco.co.uk/
Other
711 stars 227 forks source link

Selecting from temporary table #831

Closed iahmed9312 closed 10 months ago

iahmed9312 commented 10 months ago

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 commented 10 months ago

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

iahmed9312 commented 10 months ago

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));