I have the problem when i do 1 fetch it works but when i try to fetch 4 calls att the same time 1 succedes and the other 3 fails.
public IHttpActionResult GetAll() {
var products = _context.Products
.ToList();
if (products == null)
return NotFound();
return Ok(products.Select(x => CreateDto(x)));
}
This is the error
An error has occurred.","ExceptionMessage":"There is already
an open DataReader associated with this Command which must be
closed first.
When i google this they suggest i add to the connectionsstring
MultipleActiveResultSets=True
Then i get another error
ExecuteReader requires an open and available Connection.
The connection's current state is open.
The suggested by google is then. That i use the dbcontext wrong ExecuteReader requires an open and available Connection. The connection's current state is Connecting
My dbcontext looks like. So im not doing any funky with that.
public class PContext : DbContext {
public IDbSet<Products> Products{ get; set; }
}
When im return Ok(products.Select(x => CreateDto(x))); in the first line of code i do a lot of selects and things like that. If i remove some heavy code here it works. But it feels like the problem is that this stuff cant handle multiple calls. I mean it should depend on the size of the job it should return when its finished.
Any ideas?