C
C#2y ago
Hankie

❔ Npgsql.NpgsqlOperationInProgressException: "A command is already in progress: SELECT * FROM games"

When executing the GetAll() method, the Pgsql error is returned.Npgsql Operation In Progress Exception: "A command is already in progress: SELECT * FROM games" don't know how to fix it? https://pastebin.com/ZaXiCUSJ
Pastebin
public List GetAll() { var command = Database.Get...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
7 Replies
Pobiega
Pobiega2y ago
the error doesn't appear to be in these methods, but rather how you are calling them are you doing any parallell, multithreaded or async work with these methods?
Hankie
HankieOP2y ago
no
Pobiega
Pobiega2y ago
oh sorry I missed the problem 🙂
public List<Game> GetAll()
{
var command = Database.GetCommand("SELECT * FROM games");
var games = new List<Game>();
using(var reader = command.ExecuteReader())
{
while (reader.Read())
{
var publisher = publisherService.PublisherById(reader.GetInt32(reader.GetOrdinal("publisher_id")));
var genre = genreService.GenreById(reader.GetInt32(reader.GetOrdinal("genre_id")));
public List<Game> GetAll()
{
var command = Database.GetCommand("SELECT * FROM games");
var games = new List<Game>();
using(var reader = command.ExecuteReader())
{
while (reader.Read())
{
var publisher = publisherService.PublisherById(reader.GetInt32(reader.GetOrdinal("publisher_id")));
var genre = genreService.GenreById(reader.GetInt32(reader.GetOrdinal("genre_id")));
publisherService.PublisherById will try to initiate a new db query while reading the results from one thats not allowed you need to finish one before you can start a new if you want publisher/genre info at the same time, write a better query
Hankie
HankieOP2y ago
i need to use join?
Hankie
HankieOP2y ago
ok, thank you ❤️
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server