Exemple #1
0
 public virtual DataTable GetResults(SqlGenerator generator)
 {
     DataTable result = new DataTable();
     using (var conn = CreateConnection())
     {
         using (var cmd = conn.CreateCommand())
         {
             cmd.CommandTimeout = CommandTimeout;
             generator.UpdateCommand(cmd);
             using (var adapter = CreateDataAdapter())
             {
                 adapter.SelectCommand = cmd;
                 adapter.Fill(result);
             }
         }
     }
     return result;
 }
        private int Execute(SqlGenerator gen)
        {
            using (var cmd = _conn.CreateCommand())
            {
                gen.UpdateCommand(cmd);

                System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter((System.Data.SqlClient.SqlCommand)cmd); //we are now tieing ourselves to SQL
                System.Data.DataTable tbl = new System.Data.DataTable();
                adapter.Fill(tbl);

                return tbl.Rows.Count;
            }
        }