/// <summary> /// Returns results from using an SqlExpression lambda. E.g: /// <para>db.Select(db.From<Person>().Where(x => x.Age > 40))</para> /// </summary> public static List <T> Select <T>(this IDbConnection dbConn, ISqlExpression expression, object anonType = null) { if (anonType != null) { return(dbConn.Exec(dbCmd => dbCmd.SqlList <T>(expression.SelectInto <T>(), anonType))); } if (expression.Params != null && expression.Params.Any()) { return(dbConn.Exec(dbCmd => dbCmd.SqlList <T>(expression.SelectInto <T>(), expression.Params.ToDictionary(param => param.ParameterName, param => param.Value)))); } return(dbConn.Exec(dbCmd => dbCmd.SqlList <T>(expression.SelectInto <T>(), expression.Params))); }
/// <summary> /// Returns results from using an SqlExpression lambda. E.g: /// <para>db.Single(db.From<Person>().Where(x => x.Age > 40))</para> /// </summary> public static T Single <T>(this IDbConnection dbConn, ISqlExpression expression) { return(dbConn.Exec(dbCmd => dbCmd.Single <T>(expression.SelectInto <T>(), expression.Params))); }
/// <summary> /// Returns results from using an SqlExpression lambda. E.g: /// <para>db.SelectAsync(db.From<Person>().Where(x => x.Age > 40))</para> /// </summary> public static Task <List <T> > SelectAsync <T>(this IDbConnection dbConn, ISqlExpression expression, CancellationToken token = default(CancellationToken)) { return(dbConn.Exec(dbCmd => dbCmd.SqlListAsync <T>(expression.SelectInto <T>(), expression.Params, token))); }
/// <summary> /// Returns results from using an SqlExpression lambda. E.g: /// <para>db.Select(db.From<Person>().Where(x => x.Age > 40))</para> /// </summary> public static List <T> Select <T>(this IDbConnection dbConn, ISqlExpression expression, object anonType = null) { return(dbConn.Exec(dbCmd => dbCmd.SqlList <T>(expression.SelectInto <T>(), anonType))); }
/// <summary> /// Returns results from using an SqlExpression lambda. E.g: /// <para>db.SingleAsync(db.From<Person>().Where(x => x.Age > 40))</para> /// </summary> public static Task <T> SingleAsync <T>(this IDbConnection dbConn, ISqlExpression expression, object anonType = null, CancellationToken token = default(CancellationToken)) { return(dbConn.Exec(dbCmd => dbCmd.SingleAsync <T>(expression.SelectInto <T>(), anonType, token))); }
/// <summary> /// Returns results from using an SqlExpression lambda. E.g: /// <para>db.SingleAsync(db.From<Person>().Where(x => x.Age > 40))</para> /// </summary> public static Task <T> SingleAsync <T>(this IDbConnection dbConn, ISqlExpression expression, CancellationToken token = default) { return(dbConn.Exec(dbCmd => dbCmd.SingleAsync <T>(expression.SelectInto <T>(QueryType.Single), expression.Params, token))); }