Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Return Multiple Tables from a Data Set.
- /// </summary>
- /// <param name="Tables">Tables for which to query</param>
- /// <param name="Filters">
- /// Array of filters for each table.
- /// Must contain a filter for each table in the form of FIELD0 equatable @param_val_0, ..., FIELDN equatable @param_val_N
- /// Filter strings can be null.
- /// </param>
- /// <param name="Parameters">
- /// Array of an array of objects for each filter.
- /// Must contain an object set for each table.
- /// Object sets can be null.
- /// </param>
- public async Task GetTables( string[ ] Tables, string[ ] Filters, object[ ][ ] Parameters ) {
- this.Adapters = new MySqlDataAdapter[Tables.Length];
- int FilterIndex;
- object[ ] ParameterSet = null;
- string Query = null, Filter = null;
- foreach ( string Table in Tables ) {
- FilterIndex = Tables.ToList( ).IndexOf( Table );
- Filter = Filters[FilterIndex];
- ParameterSet = Parameters[FilterIndex];
- Query = "SELECT * FROM " + Table + " WHERE ";
- if ( string.IsNullOrEmpty( Filter ) )
- Query += "1;";
- else
- Query += Filter + ";";
- MySqlDataAdapter Adapter = new MySqlDataAdapter( new MySqlCommand( Query ) { CommandType = CommandType.Text } );
- if ( ParameterSet != null )
- for ( int x = 0; x < ParameterSet.Length; x++ )
- Adapter.SelectCommand.Parameters.AddWithValue( "@param_val_" + x, ParameterSet[x] );
- Adapter.TableMappings.Add( Table, Table );
- this.Adapters[Tables.ToList( ).IndexOf( Table )] = Adapter;
- }
- if (Methods.IsOnline)
- await this.ReadTables( );
- }
- //SQL.Adapters :
- private MySqlDataAdapter[ ] Adapters;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement