c# - Entity Framework. Cannot retrieve data -


i met strange behavior , don't have idea may related to. tried retrieve data 2 ways: pure linq , stored procedure data not coming back. no errors or exceptions. on sql server side can see profiler stored procedure executed.

public async task<ienumerable<ordersdto>> getall(int userid) {     ordersdto[] result;     try     {         sqlparameter param = new sqlparameter("@userid", userid);         result = await _db.database.sqlquery<ordersdto>("userorders @userid", param).toarrayasync();         //var result = await _db.order.where(x=> x.customerid == 1)         //    .include(x => x.orderdetails)         //    .include(x => x.orderstatus)         //    .include(x => x.paymentstatus)         //    .asnotracking().toarrayasync();     }     catch (exception ex)     {         throw new exception(ex.message);     }     return result; }  

when await reached, thread returned caller. when checking await result, because you're not waiting completion of task not getting result. if run query synchronously can see desired result:

result = _db.database.sqlquery<ordersdto>("userorders @userid", param).toarray(); 

there no problem run code asynchronously, should check result when task completed:


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -