How Do I Use CancellationTokenSource With DbContext.Database.SqlQuery(Sp, Param)?
I'm using EF6.2 and running a stored procedure with a return type.
var task = Db.Database.SqlQuery<ResultType>(sp, params).ToListAsync();
foreach(var result in task.Result)
{
var row = result;
}
Our current solution has cancellation tokens but doesn't return anything:
var task = Db.Database.ExecuteSqlCommandAsync(sp, tokenSource.Token, param);
SqlQuery only has the one method signiture, and I cant see anything about canceling in the documentation
How do I use the first method AND include a cancellation token? Edit: Or is there another method I should use?
Additional Info: Our current solution ExecuteSqlCommandAsync() returns a task that just has a "completed" int status as the return type. The stored procedures I'm calling was just an INSERT... but I need to change it to a SELECT so we can produce files with the results.
So I need a EF method that returns a task of type "ResultType" so I can foreach through them and produce our files.
SqlQuery<>() does this... but without the ability to add a cancellation token (by the looks of it anyway, hence the question)