C
C#15mo 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
Pobiega15mo 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
Hankie15mo ago
no
Pobiega
Pobiega15mo 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
Hankie15mo ago
i need to use join?
Hankie
Hankie15mo ago
ok, thank you ❤️
Accord
Accord15mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.