SQL Server procedure params problem


I have a problem with actual version of Radzen for Mac, with Blazor. Any procedure passed with parameters raise the error: "The best overloaded method match for [... my procedure...] has some invalid arguments"

I debug this in visual studio for Mac, to retrieve the error. My procedure is executed below, with the auto-generated:

var items = context.DominioPorIds.FromSqlRaw("EXEC [rad].[DomínioPorId] @usuario_id={0}, @Id={1}", usuario_id, Id);

If I execute the code below, all works fine:

var items = context.DominioPorIds.FromSqlRaw("EXEC [rad].[DomínioPorId] @usuario_id="abc", @Id=123");

That is, the automatically generated code is being generated with some problem at some point. Has anyone identified this problem?

PS: the problem is solved by setting the integer type parameters as follows: instead of ${parameter} just define it like this - ${int.Parse(parameter)}

however, I subsequently had other errors also referring to the parameters in the procedure. They were resolved by changing the System.Data.SqlClient reference to Microsoft.Data.SqlClient.

I need to fix these issues please :slight_smile:

FromSqlRaw method parameters argument is object[] - you can pass any type of value:

public static IQueryable<TEntity> FromSqlRaw<TEntity>([NotNullAttribute] this DbSet<TEntity> source, [NotNullAttribute][NotParameterized] string sql, [NotNullAttribute] params object[] parameters) where TEntity : class;

If your procedure needs int you need to pass int.

You are right about Microsoft.Data.SqlClient - we will use it instead System.Data.SqlClient.

Ok, I go wait the update; Thanks!