internal static int getIntSingleResult(DbConnection con, string sql) { int result = 0; using (var reader = new DbCommandFactory(con, sql).Create().ExecuteReader()) { while (reader.Read()) { result = reader.GetInt32(0); } } return(result); }