internal static Task <List <T> > WhereAsync <T>(this IDbCommand dbCmd, object anonType, CancellationToken token)
        {
            dbCmd.SetFilters <T>(anonType);

            return(OrmLiteReadCommandExtensions.IsScalar <T>()
                ? dbCmd.ColumnAsync <T>(null, token)
                : dbCmd.ConvertToListAsync <T>(null, token));
        }
        internal static Task <List <TModel> > SelectAsync <TModel>(this IDbCommand dbCmd, Type fromTableType, string sqlFilter, object anonType, CancellationToken token)
        {
            if (anonType != null)
            {
                dbCmd.SetParameters(fromTableType, anonType, excludeDefaults: false);
            }
            var sql = OrmLiteReadCommandExtensions.ToSelect <TModel>(dbCmd.GetDialectProvider(), fromTableType, sqlFilter);

            return(dbCmd.ConvertToListAsync <TModel>(sql, token));
        }
        internal static Task <T> SingleAsync <T>(this IDbCommand dbCmd, string sql, object anonType, CancellationToken token)
        {
            if (OrmLiteReadCommandExtensions.IsScalar <T>())
            {
                return(dbCmd.ScalarAsync <T>(sql, anonType, token));
            }

            dbCmd.SetParameters <T>(anonType, excludeDefaults: false);

            return(dbCmd.ConvertToAsync <T>(dbCmd.GetDialectProvider().ToSelectStatement(typeof(T), sql), token));
        }
        internal static Task <List <T> > SqlColumnAsync <T>(this IDbCommand dbCmd, string sql, Dictionary <string, object> dict, CancellationToken token)
        {
            if (dict != null)
            {
                dbCmd.SetParameters(dict, false);
            }
            dbCmd.CommandText = sql;

            return(OrmLiteReadCommandExtensions.IsScalar <T>()
                ? dbCmd.ColumnAsync <T>(null, token)
                : dbCmd.ConvertToListAsync <T>(null, token));
        }
        internal static Task <List <T> > SqlColumnAsync <T>(this IDbCommand dbCmd, string sql, object anonType, CancellationToken token)
        {
            if (anonType != null)
            {
                dbCmd.SetParameters <T>(anonType, excludeDefaults: false);
            }
            dbCmd.CommandText = sql;

            return(OrmLiteReadCommandExtensions.IsScalar <T>()
                ? dbCmd.ColumnAsync <T>(null, token)
                : dbCmd.ConvertToListAsync <T>(null, token));
        }
        internal static Task <List <T> > SelectAsync <T>(this IDbCommand dbCmd, string sql, object anonType, CancellationToken token)
        {
            if (anonType != null)
            {
                dbCmd.SetParameters <T>(anonType, excludeDefaults: false);
            }
            dbCmd.CommandText = dbCmd.GetDialectProvider().ToSelectStatement(typeof(T), sql);

            return(OrmLiteReadCommandExtensions.IsScalar <T>()
                ? dbCmd.ColumnAsync <T>(null, token)
                : dbCmd.ConvertToListAsync <T>(null, token));
        }
        internal static Task <List <T> > SelectAsync <T>(this IDbCommand dbCmd, string sql, Dictionary <string, object> dict, CancellationToken token)
        {
            if (dict != null)
            {
                dbCmd.SetParameters((IDictionary <string, object>)dict, (bool)false);
            }

            dbCmd.CommandText = dbCmd.GetDialectProvider().ToSelectStatement(typeof(T), sql);

            return(OrmLiteReadCommandExtensions.IsScalar <T>()
                ? dbCmd.ColumnAsync <T>(null, token)
                : dbCmd.ConvertToListAsync <T>(null, token));
        }
 internal static Task <T> ScalarAsync <T>(this IDataReader reader, IOrmLiteDialectProvider dialectProvider, CancellationToken token)
 {
     return(dialectProvider.ReaderRead(reader, () =>
                                       OrmLiteReadCommandExtensions.ToScalar <T>(dialectProvider, reader), token));
 }
 internal static async Task <long> InsertIntoSelectAsync <T>(this IDbCommand dbCmd, ISqlExpression query, Action <IDbCommand> commandFilter, CancellationToken token) =>
 OrmLiteReadCommandExtensions.ToLong(await dbCmd.InsertIntoSelectInternal <T>(query, commandFilter).ExecNonQueryAsync(token: token));
Esempio n. 10
0
        public static async Task <long> LongScalarAsync(this IDbCommand dbCmd, CancellationToken token)
        {
            var ret = await dbCmd.GetDialectProvider().ExecuteScalarAsync(dbCmd, token).ConfigAwait();

            return(OrmLiteReadCommandExtensions.ToLong(ret));
        }
        internal static Task <List <TModel> > SelectFmtAsync <TModel>(this IDbCommand dbCmd, CancellationToken token, Type fromTableType, string sqlFilter, params object[] filterParams)
        {
            var sql = OrmLiteReadCommandExtensions.ToSelectFmt <TModel>(dbCmd.GetDialectProvider(), fromTableType, sqlFilter, filterParams);

            return(dbCmd.ConvertToListAsync <TModel>(sql.ToString(), token));
        }