private IDbDataParameter GetParameter() { string typeName = AssemblyProvider.GetInstance(Configuration.ProviderName).GetParameterType(); IDbDataParameter dbParam = (IDbDataParameter)AssemblyProvider.GetInstance(Configuration.ProviderName).DBProviderAssembly.CreateInstance(typeName); return(dbParam); }
public static AssemblyProvider GetInstance() { /*if (_assemblyProvider == null) * {*/ _assemblyProvider = new AssemblyProvider(); //} return(_assemblyProvider); }
public static AssemblyProvider GetInstance(string providerName) { /*if (_assemblyProvider == null) * {*/ _assemblyProvider = new AssemblyProvider(providerName); //} return(_assemblyProvider); }
private ConstructorInfo GetDataAdapterConstructor(string prov = null) { string typeName = AssemblyProvider.GetInstance(prov).GetDataAdapterType(); Type cmdType = AssemblyProvider.GetInstance(prov).DBProviderAssembly.GetType(AssemblyProvider.GetInstance(prov).GetCommandType()); Type dataAdapterType = AssemblyProvider.GetInstance(prov).DBProviderAssembly.GetType(AssemblyProvider.GetInstance(prov).GetDataAdapterType()); ConstructorInfo constructor = dataAdapterType.GetConstructor(new Type[] { cmdType }); return(constructor); }
/// <summary> /// Obtiene una tabla según un query proporcionado /// </summary> /// <param name="sqlCommand"></param> /// <param name="paramCollection"></param> /// <param name="connection"></param> /// <param name="tableName"></param> /// <param name="commandType"></param> /// <returns></returns> internal DataTable GetDataTable(string sqlCommand, DBParameterCollection paramCollection, IDbConnection connection, string tableName, CommandType commandType) { DataTable table = null; if (tableName != string.Empty) { table = new DataTable(tableName); } else { table = new DataTable(); } IDbCommand command = null; if (paramCollection != null) { if (paramCollection.Parameters.Count > 0) { command = _commandBuilder.GetCommand(sqlCommand, connection, paramCollection, commandType); } else { command = _commandBuilder.GetCommand(sqlCommand, connection, commandType); } } else { command = _commandBuilder.GetCommand(sqlCommand, connection, commandType); } IDataAdapter adapter = GetDataAdapter(command); string typeName = AssemblyProvider.GetInstance(Configuration.ProviderName).GetDataAdapterType(); Type cmdType = AssemblyProvider.GetInstance(Configuration.ProviderName).DBProviderAssembly.GetType(AssemblyProvider.GetInstance(Configuration.ProviderName).GetCommandType()); Type dataAdapterType = AssemblyProvider.GetInstance(Configuration.ProviderName).DBProviderAssembly.GetType(AssemblyProvider.GetInstance(Configuration.ProviderName).GetDataAdapterType()); ConstructorInfo constructor = dataAdapterType.GetConstructor(new Type[] { cmdType }); adapter = (IDataAdapter)constructor.Invoke(new object[] { command }); MethodInfo method = dataAdapterType.GetMethod("Fill", new Type[] { typeof(DataTable) }); try { method.Invoke(adapter, new object[] { table }); } catch (Exception err) { throw err; } return(table); }
private IDbCommand GetCommand(string provi) { string typeName = string.Empty; IDbCommand command = null; if (provi != null) { typeName = AssemblyProvider.GetInstance(provi).GetCommandType(); command = (IDbCommand)AssemblyProvider.GetInstance(provi).DBProviderAssembly.CreateInstance(typeName); } else { typeName = AssemblyProvider.GetInstance(Configuration.ProviderName).GetCommandType(); command = (IDbCommand)AssemblyProvider.GetInstance(Configuration.ProviderName).DBProviderAssembly.CreateInstance(typeName); } return(command); }
/// <summary> /// Establece la conexión a la BD solicitada /// </summary> /// <returns>Conexión a la BD</returns> internal IDbConnection GetConnection() { string typeName = AssemblyProvider.GetInstance(_providerName).GetConnectionType(); IDbConnection connection = (IDbConnection)AssemblyProvider.GetInstance(_providerName).DBProviderAssembly.CreateInstance(typeName); connection.ConnectionString = _connectionString; try { connection.Open(); } catch (Exception err) { throw err; } return(connection); }