Пример #1
0
 /// <summary>
 /// getDataTable
 /// </summary>
 /// <param name="commandText"></param>
 /// <param name="commandType"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public DataTable getDataTable(string commandText, CommandType commandType, IDbDataParameter[] parameters = null)
 {
     using (var connection = database.createConnection())
     {
         connection.Open();
         using (var command = database.createCommand(commandText, commandType, connection))
         {
             if (null != parameters)
             {
                 foreach (var parameter in parameters)
                 {
                     command.Parameters.Add(parameter);
                 }
             }
             var dataset     = new DataSet();
             var dataAdapter = database.createAdapter(command);
             dataAdapter.Fill(dataset);
             return(dataset.Tables[0]);
         }
     }
 }