"A second operation started on this context before a previous operation completed." I can't figure out how to get rid of this...
OK, so here's what's going on. I'm building a note taking application in ASP.NET Core 2.0 MVC, for practice/figuring things out. I'm getting this exception:
"Invalid Operation Exception: A second operation started on this context before a previous operation completed."
On the _context.Notes.... Linq query. Code for the action looks like this.
`public IActionResult Index() { var notes = _context.Notes .Where(n => n.Id == _userId) .OrderByDescending(n => n.TimeCreated) .ToList();
if (notes.Any()) { return View( new IndexViewModel { Notes = notes }); } else { return View(); }
}`
I've tried to refactor it using async but I guess I don't know how to do that very well, because i couldn't get it to work. Is there anyway around this other that pulling this data asyncronously? Or should i just buck up and learn how to do the whole asyncronous thing better?
0 comments:
Post a Comment