I would like my code to return a value but it returns me:
System.Collections.Generic.List`1[Dapper.SqlMapper+DapperRow]
I can't solve and make a right output process.
public static string Test()
{
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{
var vartest = cnn.Query("select grado from utenti where id='10'");
//var result = output.ToDictionary(row => (string)row.Grado, row => (string)row.Nome ) ; (commento)
//Console.WriteLine(vartest);
cnn.Close();
return vartest.ToString();
}
}
Query
and Query<T>
return multiple rows; Query
is for dynamic
rows; Query<T>
is for typed rows. There are QueryFirst[<T>]
and QuerySingle[<T>]
for single rows.
If you're after a single value of a known type, then perhaps:
var vartest = cnn.QuerySingle<string>("select grado from utenti where id='10'");