Exemplo n.º 1
0
 public List <T> RetriveFromDatabaseCapped <T>(MySqlConnection Connection, int limit, string Command, params object[] Arguments)
 {
     if (Connection.State != System.Data.ConnectionState.Open)
     {
         Connection.Open();
     }
     using (MySqlCommand Command_ = new MySqlCommand(Command, Connection))
     {
         for (int i = 0; i < Arguments.Length; i++)
         {
             if (Command.Contains($"{{{i}}}"))
             {
                 Command_.Parameters.AddWithValue($"{{{i}}}", Arguments[i]);
             }
             if (Command.Contains($"@{i}"))
             {
                 Command_.Parameters.AddWithValue($"@{i}", Arguments[i]);
             }
         }
         using (DbDataReader Reader = Command_.ExecuteReader())
         {
             SQLConverter Converter = new SQLConverter();
             Converter.TypeHelper = IndexedHelper;
             return(Converter.ReadModelsFromReader <T>(Reader, limit));
         }
     }
 }
Exemplo n.º 2
0
 public List <T> RetriveClassesFromDatabase <T>(MySqlConnection Connection, string Command, params object[] Arguments)
 {
     if (Connection.State != System.Data.ConnectionState.Open)
     {
         Connection.Open();
     }
     using (MySqlCommand Command_ = new MySqlCommand(Command, Connection))
     {
         for (int i = 0; i < Arguments.Length; i++)
         {
             if (Command.Contains($"{{{i}}}"))
             {
                 Command_.Parameters.AddWithValue($"{{{i}}}", Arguments[i]);
             }
             if (Command.Contains($"@{i}"))
             {
                 Command_.Parameters.AddWithValue($"@{i}", Arguments[i]);
             }
         }
         using (MySqlDataReader Reader = Command_.ExecuteReader())
         {
             SQLConverter Converter = new SQLConverter();
             return(Converter.ReadClasses <T>(Reader));
         }
     }
 }