コード例 #1
0
        public static List <Dictionary <string, object> > SelectAll(MysqlQuery query)
        {
            var allValues = new List <Dictionary <string, object> >();

            lock (_lock)
            {
                MySqlConnection Connection = GetConnection(query);
                try
                {
                    Connection.Open();
                    MySqlCommand    command     = query.GetMysqlCommand(Connection);
                    MySqlDataReader dataReader  = command.ExecuteReader();
                    DataTable       schemaTable = null;
                    while (dataReader.Read())
                    {
                        allValues.Add(GetValues(dataReader, schemaTable));
                    }
                    dataReader.Close();
                }
                catch (MySqlException ex)
                {
                    Log.WarnException("MySql", ex);
                }
                finally
                {
                    Connection.Close();
                }
            }

            return(allValues);
        }
コード例 #2
0
 public static bool Query(MysqlQuery query)
 {
     lock (_lock)
     {
         MySqlConnection Connection = GetConnection(query);
         bool            Result     = false;
         try
         {
             Connection.Open();
             MySqlCommand Command = query.GetMysqlCommand(Connection);
             int          t       = Command.ExecuteNonQuery();
             Result = !(t == -1 || t == 0);
         }
         catch (MySqlException ex)
         {
             Log.WarnException("MySql", ex);
             Result = false;
         }
         finally
         {
             Connection.Close();
         }
         return(Result);
     }
 }
コード例 #3
0
 public static object Result(MysqlQuery query)
 {
     lock (_lock)
     {
         MySqlConnection Connection = GetConnection(query);
         object          Result     = null;
         try
         {
             Connection.Open();
             MySqlCommand Command = query.GetMysqlCommand(Connection);
             Result = Command.ExecuteScalar();
         }
         catch (MySqlException ex)
         {
             Log.WarnException("MySql", ex);
             Result = null;
         }
         finally
         {
             Connection.Close();
         }
         return(Result);
     }
 }
コード例 #4
0
        private static MySqlConnection GetConnection(MysqlQuery query)
        {
            MySqlConnection connection = new MySqlConnection(Auth.ToString());

            return(connection);
        }