Hello team Radzen!
I found a bug in generated SQL Server-based code regarding a procedure that returns only output parameters...
I take the result of the procedure and set it in a parameter. But, the generated property type is getting 'IEnumerable '
The problem? First, the C # class in code is named 'GetInfoClienteResult'. Second, the result is not an IEnumerable actually. It is a single result. If I rename the 'GetInfoClient' class to 'GetInfoClienteResult' manually, I have the following error:
If I manually correct the generated property type, the application works, but the Radzen interface will get the above error.
enchev
December 18, 2019, 3:36pm
2
Hi @raphaelz ,
Can you post your stored procedure SQL script to test it locally?
Best Regards,
Vladimir
I adapted the concept of the procedure so you can test even without the data. It follows:
CREATE PROCEDURE [RadzenTestObterInfoCliente]
@Id INT,
@Nome varchar(255) OUTPUT,
@Info varchar(max) OUTPUT
AS
BEGIN
SET @Nome = 'NAME XPTO';
SET @Info = CONCAT('THE ID IS ', @Id);
RETURN;
END
enchev
December 19, 2019, 6:13am
4
Just tested your procedure and here is the code generated by Radzen:
Blazor
public partial class SampleService
{
private readonly SampleContext context;
private readonly NavigationManager navigationManager;
public SampleService(SampleContext context, NavigationManager navigationManager)
{
this.context = context;
this.navigationManager = navigationManager;
}
public async Task<Models.Sample.RadzenTestObterInfoClienteResult> RadzenTestObterInfoClientes(int? Id)
{
OnRadzenTestObterInfoClientesDefaultParams(ref Id);
SqlParameter[] @params =
{
new SqlParameter("@returnVal", SqlDbType.Int) {Direction = ParameterDirection.Output},
new SqlParameter("@Id", SqlDbType.Int) {Direction = ParameterDirection.Input, Value = Id},
new SqlParameter("@Nome", SqlDbType.VarChar, 255) {Direction = ParameterDirection.Output},
new SqlParameter("@Info", SqlDbType.VarChar, -1) {Direction = ParameterDirection.Output},
};
context.Database.ExecuteSqlRaw("EXEC @returnVal=[dbo].[RadzenTestObterInfoCliente] @Id, @Nome out, @Info out", @params);
var result = new Models.Sample.RadzenTestObterInfoClienteResult();
result.returnValue = Convert.ToInt32(@params[0].Value);
result.Nome = Convert.ToString(@params[2].Value);
result.Info = Convert.ToString(@params[3].Value);
OnRadzenTestObterInfoClientesInvoke(ref result);
return await Task.FromResult(result);
}
partial void OnRadzenTestObterInfoClientesDefaultParams(ref int? Id);
partial void OnRadzenTestObterInfoClientesInvoke(ref Models.Sample.RadzenTestObterInfoClienteResult result);
}
Angular
public partial class RadzenTestObterInfoClientesController : ODataController
{
private Data.SampleContext context;
public RadzenTestObterInfoClientesController(Data.SampleContext context)
{
this.context = context;
}
[HttpGet]
[ODataRoute("RadzenTestObterInfoClientesFunc(Id={Id})")]
public IActionResult RadzenTestObterInfoClientesFunc([FromODataUri] int? Id)
{
this.OnRadzenTestObterInfoClientesDefaultParams(ref Id);
SqlParameter[] @params =
{
new SqlParameter("@returnVal", SqlDbType.Int) {Direction = ParameterDirection.Output},
new SqlParameter("@Id", SqlDbType.Int) {Direction = ParameterDirection.Input, Value = Id},
new SqlParameter("@Nome", SqlDbType.VarChar, 255) {Direction = ParameterDirection.Output},
new SqlParameter("@Info", SqlDbType.VarChar, -1) {Direction = ParameterDirection.Output},
};
this.context.Database.ExecuteSqlCommand("EXEC @returnVal=[dbo].[RadzenTestObterInfoCliente] @Id, @Nome out, @Info out", @params);
var result = new Models.Sample.RadzenTestObterInfoClienteResult();
result.returnValue = Convert.ToInt32(@params[0].Value);
result.Nome = Convert.ToString(@params[2].Value);
result.Info = Convert.ToString(@params[3].Value);
this.OnRadzenTestObterInfoClientesInvoke(ref result);
return Ok(result);
}
partial void OnRadzenTestObterInfoClientesDefaultParams(ref int? Id);
partial void OnRadzenTestObterInfoClientesInvoke(ref Models.Sample.RadzenTestObterInfoClienteResult result);
}
Everything looks normal in my opinion or you have different result?
Here's a detailed explanation of the problem:
enchev
December 19, 2019, 1:20pm
6
I see. We will fix the type infer in one of upcoming releases and in the meantime you can overwrite it by setting the correct type.
OK; Thank you very much for your attention