public IEnumerable <string> GetTableNames() { using (OleDbConnection connection = _connectionBuilder.GetConnection(_fileConfiguration.FileName)) { DataTable schemaTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if (schemaTable != null) { for (int i = 0; i < schemaTable.Rows.Count; i++) { yield return(schemaTable.Rows[i]["TABLE_NAME"].ToString()); } } } }
public async Task <IEnumerable <T> > GetAsync(string query, object values = null) { try { using (IDbConnection db = _connectionBuilder.GetConnection()) { return(await db.QueryAsync <T>(query, values)); } } catch (Exception ex) { _logger.LogError(ex, "SqlDapper<T>/GetAsync"); throw ex; } }
public void Should_open_a_new_OleDbConnection() { _connectionString.Expect(x => x.Get(_file)).Return(TestData.UsersXlsConnectionString); using (OleDbConnection connection = _connectionBuilder.GetConnection(_file)) { Assert.IsInstanceOfType(typeof(OleDbConnection), connection); Assert.AreEqual(ConnectionState.Open, connection.State); } }
/// <summary>完成本地資料庫物件的設定</summary> /// <param name="_builder"></param> private void SetDataObject(IConnectionBuilder _builder) { this.connection = _builder.GetConnection(); this.command = _builder.GetCommand(); this.dataadapter = _builder.GetDataAdapter(); }