I am using Npgsql to access postgresql database
and I am running a query:
int a = connection.Execute(@"SELECT count(*) FROM account AS a WHERE a.account_name = 'food'");
The query will return value 4, but my
a gets -1.what is the problem here and how can I solve it?
It looks like you are using Dapper. If so, you want
Execute just returns the number of rows
int a = connection.QueryFirst<int>(@" SELECT count(*) FROM account AS a WHERE a.account_name = 'food' ");