Пример #1
0
 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());
             }
         }
     }
 }
Пример #2
0
 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;
     }
 }
Пример #3
0
            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);
                }
            }
Пример #4
0
 /// <summary>完成本地資料庫物件的設定</summary>
 /// <param name="_builder"></param>
 private void SetDataObject(IConnectionBuilder _builder)
 {
     this.connection  = _builder.GetConnection();
     this.command     = _builder.GetCommand();
     this.dataadapter = _builder.GetDataAdapter();
 }