0
I am developing an MVC application with Entity Framework in Code First.
As my database has procedures, I opted to use Sqlquery to execute the procedures, but I am thinking about this error:
Não existe mapeamento do tipo de objeto System.Data.Entity.Core.Objects.ObjectParameter para um provedor gerenciado de tipo nativo.
Follows code from the Dbcontext class:
public DTODados GetDadosProcedure(string codUsuario, string senhaCript)
{
return Database.SqlQuery<DTODados>("ProcedureGenerica",
codUsuario != null ?
new ObjectParameter("codUsuario", codUsuario) :
new ObjectParameter("codUsuario", typeof(string)),
senhaCript != null ?
new ObjectParameter("senhaCript", senhaCript) :
new ObjectParameter("senhaCript", typeof(string))
).SingleOrDefault();
}
Following this link, I tried to switch to Sqlparameter, but when executing, I threw another exception stating that the process expects the parameters, even if they were present (I tried to put the new SqlParameter("@codUsuario", codUsuario)
and without @, but it didn’t work).
Grateful to those who can help.