In a code first approach I would like
static void Main()
{
var sprocName = "sprocTesting";
var db = new EntityContext();
var result = db.Database.SqlQuery<object>(sprocName).ToList();
var json = JsonConvert.SerializeObject(result);
}
In this particular case, I will not be able to have a class to return this into, the best I can do is Object
.
This runs, but the output of result
is nothing more than a list of {object}
. The serialized json is nothing more than a bunch of empty braces
[{},{},{}....{}]
The count does match what I would expect from this stored procedure (5,228 results).
Is what I'm looking to do even doable or am I just missing something?
I should mention that if I do create a class to dump this into, then it works fine. But this is just one example where the stored procedure name will be passed in from another table, so I won't be able to build out a class for every possible result set, hence the need for the generics.