Reputation: 466
It needs just a second to retreive all the data and convert it to IEnumerable<MYORDERS>
with micro-ORM dapper. But within the return OK(result)
-statement it takes several minutes to get the result. I think it is because JSON-mapping.
Why does it take so long and what is a possible good solution?
public object GetOrders()
{
using (var conn = new SqlConnection(StaticValues.ConnString))
{
IEnumerable<MYORDERS> result =
//Micro-ORM dapper used
conn.Query<MYORDERS>("SELECT * FROM MY_ORDER_TABLE");
//This line takes several minutes
return Ok(result);
}
}
My POCO MYORDERS
got like 70 properties. The result got 900 rows/POCOs. I thought an API should also easily transfer this amount of data.
Edit: Ok, I see that JSON-mapping isn't my problem. It just needs minutes to create the output:
//no serializing problem
var json = Newtonsoft.Json.JsonConvert.SerializeObject(await result);
//returning json needs some minutes
return json;
The output-json-string got 1,2 millions of characters. Maybe it is because the swagger-ui.. Can't belive 1 million characters will take this amount of time...
I will update this question again when I finally deployed it on our IIS. This will take a few days.
Upvotes: 1
Views: 1237
Reputation: 466
Like @phuzi said as a comment swagger-ui forced the lag... An usual request with postman just takes some milliseconds....
Thank you everyone!
Upvotes: 1
Reputation: 43860
I would try this
public ActionResult<IEnumerable<MYORDERS>> GetOrders()
{
... your code
}
Upvotes: 1