public void Read() { IParameterFactory parameterFactory = new SqliteParameterFactory(); IDataAdapterFactory dataAdapterFactory = new SqliteDataAdapterFactory(); IConnectionFactory connectionFactory = new SqliteConnectionFactory(); using (var connection = connectionFactory.Open(_connectionString)) using (var command = new Command(connection, parameterFactory)) using (var reader = new SqlReader(connection, parameterFactory, dataAdapterFactory)) { command.Execute("drop table if exists ReadTest"); command.Execute("create table if not exists ReadTest(TestColumn text)"); //command.Execute("insert into ReadTest values(null)"); command.Execute("insert into ReadTest values('one')"); command.Execute("insert into ReadTest values('two')"); var dataSet = reader.Read("select * from ReadTest"); //reader.Prepare("select * from ReadTest"); //using (var dataReader = reader.ExecuteReader(null)) //{ // while (dataReader.Read()) // { // for (var i = 0; i < dataReader.FieldCount; ++i) // { // var isnull = dataReader.IsDBNull(i); // var o = dataReader.GetValue(i); // } // } //} Assert.IsNotNull(dataSet); Assert.AreEqual(1, dataSet.Tables.Count); Assert.IsTrue(dataSet.Tables[0].Rows.Count > 0); } }
public SqliteDataComponentFactory(RetryOptions retryOptions, string connectionString) : base() { _connectionFactory = String.IsNullOrEmpty(connectionString) ? new SqliteConnectionFactoryWithRetry(retryOptions) : new SqliteConnectionFactoryWithRetry(retryOptions, connectionString); _transactionFactory = new SqliteTransactionFactoryWithRetry(retryOptions); _dataAdapterFactory = new SqliteDataAdapterFactory(); _parameterFactory = new SqliteParameterFactory(); }
public SqliteDataComponentFactory(string connectionString) : base() { _connectionFactory = String.IsNullOrEmpty(connectionString) ? new SqliteConnectionFactory() : new SqliteConnectionFactory(connectionString); _transactionFactory = new TransactionFactory(); _dataAdapterFactory = new SqliteDataAdapterFactory(); _parameterFactory = new SqliteParameterFactory(); }
public SqliteDataComponentFactory(SqliteTransientRetryPolicy retryPolicy, IConnectionStringFactory connectionStringFactory) : base() { _connectionFactory = connectionStringFactory == null ? new SqliteConnectionFactoryWithRetry(retryPolicy) : new SqliteConnectionFactoryWithRetry(retryPolicy, connectionStringFactory); _transactionFactory = new SqliteTransactionFactoryWithRetry(retryPolicy); _dataAdapterFactory = new SqliteDataAdapterFactory(); _parameterFactory = new SqliteParameterFactory(); }
public SqliteDataComponentFactory(IConnectionStringFactory connectionStringFactory) : base() { _connectionFactory = connectionStringFactory == null ? new SqliteConnectionFactory() : new SqliteConnectionFactory(connectionStringFactory); _transactionFactory = new TransactionFactory(); _dataAdapterFactory = new SqliteDataAdapterFactory(); _parameterFactory = new SqliteParameterFactory(); }
public SqliteDataComponentFactory(SqliteTransientRetryPolicy retryPolicy, string connectionString) : base() { _connectionFactory = string.IsNullOrEmpty(connectionString) ? new SqliteConnectionFactoryWithRetry(retryPolicy) : new SqliteConnectionFactoryWithRetry(retryPolicy, connectionString); _transactionFactory = new SqliteTransactionFactoryWithRetry(retryPolicy); _dataAdapterFactory = new SqliteDataAdapterFactory(); _parameterFactory = new SqliteParameterFactory(); }
public void Constructor() { IParameterFactory parameterFactory = new SqliteParameterFactory(); IDataAdapterFactory dataAdapterFactory = new SqliteDataAdapterFactory(); IConnectionFactory connectionFactory = new SqliteConnectionFactory(); using (var connection = connectionFactory.Open(_connectionString)) using (var reader = new SqlReader(connection, parameterFactory, dataAdapterFactory)) { Assert.IsNotNull(reader); } }
public void CreateDataAdapter() { Assert.IsTrue(_connectionString.CompareTo(_connectionString.ToUTF8()) == 0); IDataAdapterFactory dataAdapterFactory = new SqliteDataAdapterFactory(); IConnectionFactory connectionFactory = new SqliteConnectionFactory(); using (var connection = connectionFactory.Open(_connectionString)) using (var command = connection.CreateCommand()) using (var dataAdapter = dataAdapterFactory.CreateDataAdapter(command)) { Assert.IsNotNull(dataAdapter); Assert.AreEqual(command, dataAdapter.SelectCommand); } }
public void Read_Count() { IParameterFactory parameterFactory = new SqliteParameterFactory(); IDataAdapterFactory dataAdapterFactory = new SqliteDataAdapterFactory(); IConnectionFactory connectionFactory = new SqliteConnectionFactory(); using (var connection = connectionFactory.Open(_connectionString)) using (var command = new Command(connection, parameterFactory)) using (var reader = new SqlReader(connection, parameterFactory, dataAdapterFactory)) { command.Execute("drop table if exists ReadCountTest"); command.Execute("create table if not exists ReadCountTest(TestColumn text)"); command.Execute("insert into ReadCountTest values('one')"); command.Execute("insert into ReadCountTest values('two')"); var dataSet = reader.Read("select count(*) from ReadCountTest"); Assert.IsNotNull(dataSet); Assert.AreEqual(1, dataSet.Tables.Count); Assert.AreEqual(1, dataSet.Tables[0].Rows.Count); Assert.AreEqual(2L, (long)dataSet.Tables[0].Rows[0][0]); } }
public void Read_WithParams() { IParameterFactory parameterFactory = new SqliteParameterFactory(); IDataAdapterFactory dataAdapterFactory = new SqliteDataAdapterFactory(); IConnectionFactory connectionFactory = new SqliteConnectionFactory(); using (var connection = connectionFactory.Open(_connectionString)) using (var command = new Command(connection, parameterFactory)) using (var reader = new SqlReader(connection, parameterFactory, dataAdapterFactory)) { command.Execute("drop table if exists ReadWParamsTest"); command.Execute("create table if not exists ReadWParamsTest(TestId integer primary key autoincrement, TestValue text)"); command.Execute("insert into ReadWParamsTest(TestValue) values('one')"); command.Execute("insert into ReadWParamsTest(TestValue) values('two')"); var dataSet = reader.Read("select * from ReadWParamsTest where TestId=@TestId", new Dictionary <string, object> { ["TestId"] = 1 }); Assert.IsNotNull(dataSet); Assert.AreEqual(1, dataSet.Tables.Count); Assert.AreEqual(1, dataSet.Tables[0].Rows.Count); } }