/// <summary> /// Opens the database connection string. /// </summary> /// <param name="connectionString">The connection string.</param> /// <returns>IDbConnection.</returns> /// <exception cref="System.ArgumentNullException">connectionString</exception> public virtual IDbConnection OpenDbConnectionString(string connectionString) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } var connection = new OrmLiteConnection(this) { ConnectionString = connectionString }; connection.Open(); return(connection); }
/// <summary> /// Open database connection string as an asynchronous operation. /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="token">The cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>A Task<IDbConnection> representing the asynchronous operation.</returns> /// <exception cref="System.ArgumentNullException">connectionString</exception> public virtual async Task <IDbConnection> OpenDbConnectionStringAsync(string connectionString, CancellationToken token = default) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } var connection = new OrmLiteConnection(this) { ConnectionString = connectionString }; await connection.OpenAsync(token).ConfigAwait(); return(connection); }
public void SubExpressions_with_CustomSqlExpression_and_merging_multiple_predicates() { var db = new OrmLiteConnection(new OrmLiteConnectionFactory("test", new CustomSqlServerDialectProvider())); var q = db.From <MarginItem>().Where(s => Sql.In(s.Identity, db.From <WaybillItem>() .Where(w => Sql.In(w.WaybillId, db.From <Waybill>() .Where(bb => bb.Identity == null) .And(bb => bb.Name == "test") .Select(ww => ww.Identity)) ) .Select(b => b.MarginItemId))); Assert.That(q.ToSelectStatement().NormalizeSql(), Does.Contain("@")); }