i have a problem with an sqlQuery/Exec. My Stored Procedure returns a list of entitys. But i need to append the parameterlist dynamicly.
using (MyContext db = new MyContext ())
{
var queryParam = new Dictionary<String, String>();
var arg = String.Empty;
var argList = new List<ObjectParameter>();
var sql = String.Empty;
foreach(var line in param.Split(','))
{
var obj = line.Split(':');
if (obj.Length < 2)
{
continue;
}
if (obj[1].Equals(String.Empty))
{
continue;
}
// arg = arg + "@" + obj[0] + "=" + "'" + obj[1] + "' ";
argList.Add(new ObjectParameter(obj[0], obj[1]));
}
object[] prm = argList.ToArray();
// Stored procedure ausführen und ergebniss erhalten.
var list = db.Database.SqlQuery<Dokument>("EXEC dbo.spDokumente", prm).ToList();
return AppServerHelper.AppResponse(list);
}
On runtime the Application returns that the object type does not match ne internal providers. I dont have a clue to solve this problem!