public static List <string> FetchString(this DbConnection connection, string sql) { List <string> list = new List <string>(); using (FbCommand cmd = connection.CreateCommand(sql)) { list.AddRange(cmd.Read(x => x.GetTrimmedString(0))); } return(list); }
private static List <string> FetchString(this DbConnection connection, string sql, string tablename) { List <string> list = new List <string>(); using (FbCommand cmd = connection.CreateCommand(sql)) { cmd.Parameters.Add("@tableName", FbDbType.VarChar).Value = tablename; list.AddRange(cmd.Read(x => x.GetTrimmedString(0))); } return(list); }
/// <summary> /// Returns a list of resulted rows represented as arrays of objects. /// </summary> /// <param name="query"></param> /// <returns></returns> public List <object[]> FetchAll(string query) { var returnable = new List <object[]>(); var reader = new FbCommand(query, _conn).ExecuteReader(); while (reader.Read()) { int limit = reader.FieldCount; var row = new object[limit]; for (int i = 0; i < limit; i++) { row[i] = reader.GetValue(i); } returnable.Add(row); } return(returnable); }