/// <summary>
        /// Returns results from using an SqlExpression lambda. E.g:
        /// <para>db.Select(db.From&lt;Person&gt;().Where(x =&gt; x.Age &gt; 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&lt;Person&gt;().Where(x =&gt; x.Age &gt; 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)));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns results from using an SqlExpression lambda. E.g:
 /// <para>db.SelectAsync(db.From&lt;Person&gt;().Where(x =&gt; x.Age &gt; 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)));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns results from using an SqlExpression lambda. E.g:
 /// <para>db.Select(db.From&lt;Person&gt;().Where(x =&gt; x.Age &gt; 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&lt;Person&gt;().Where(x =&gt; x.Age &gt; 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)));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns results from using an SqlExpression lambda. E.g:
 /// <para>db.SingleAsync(db.From&lt;Person&gt;().Where(x =&gt; x.Age &gt; 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)));
 }