Esempio n. 1
0
        internal static Task <T> SingleAsync <T>(this IDbCommand dbCmd, SqlExpression <T> expression, CancellationToken token)
        {
            string sql = expression.Limit(1).SelectInto <T>();

            return(dbCmd.ExprConvertToAsync <T>(sql, expression.Params, token));
        }
 public IUntypedSqlExpression Limit(int skip, int rows)
 {
     q.Limit(skip, rows);
     return(this);
 }
Esempio n. 3
0
 /// <summary>
 /// Returns true if the Query returns any records that match the supplied SqlExpression, E.g:
 /// <para>db.ExistsAsync(db.From&lt;Person&gt;().Where(x =&gt; x.Age &lt; 50))</para>
 /// </summary>
 public static Task <bool> ExistsAsync <T>(this IDbConnection dbConn, SqlExpression <T> expression, CancellationToken token = default)
 {
     return(dbConn.Exec(dbCmd => dbCmd.ScalarAsync(expression.Limit(1).Select("'exists'"), token).Then(x => x != null)));
 }
 /// <summary>
 /// Returns true if the Query returns any records that match the supplied SqlExpression, E.g:
 /// <para>db.Exists(db.From&lt;Person&gt;().Where(x =&gt; x.Age &lt; 50))</para>
 /// </summary>
 public static bool Exists <T>(this IDbConnection dbConn, SqlExpression <T> expression)
 {
     return(dbConn.Exec(dbCmd => dbCmd.Scalar(expression.Limit(1).Select("'exists'"))) != null);
 }
        internal static T Single <T>(this IDbCommand dbCmd, SqlExpression <T> q)
        {
            string sql = q.Limit(1).SelectInto <T>();

            return(dbCmd.ExprConvertTo <T>(sql, q.Params, onlyFields: q.OnlyFields));
        }
Esempio n. 6
0
        internal static T Single <T>(this IDbCommand dbCmd, SqlExpression <T> expression)
        {
            string sql = expression.Limit(1).ToSelectStatement();

            return(dbCmd.ExprConvertTo <T>(sql));
        }
Esempio n. 7
0
        internal static T Single <T>(this IDbCommand dbCmd, SqlExpression <T> expression)
        {
            string sql = expression.Limit(1).SelectInto <T>();

            return(dbCmd.ExprConvertTo <T>(sql, expression.Params));
        }
Esempio n. 8
0
        internal static T Single <T>(this IDbCommand dbCmd, SqlExpression <T> expression, List <string> fieldNames = null)
        {
            string sql = expression.Limit(1).SelectInto <T>(fieldNames);

            return(dbCmd.ExprConvertTo <T>(sql));
        }