예제 #1
0
        internal static Task <List <TModel> > SelectFmtAsync <TModel>(this IDbCommand dbCmd, CancellationToken token, Type fromTableType, string sqlFilter, params object[] filterParams)
        {
            var sql =
                OrmLiteReadCommandExtensionsLegacy.ToSelectFmt <TModel>(dbCmd.GetDialectProvider(), fromTableType, sqlFilter, filterParams);

            return(dbCmd.ConvertToListAsync <TModel>(sql, token));
        }
예제 #2
0
        internal static Task <List <T> > SqlListAsync <T>(this IDbCommand dbCmd, string sql, Action <IDbCommand> dbCmdFilter, CancellationToken token)
        {
            dbCmdFilter?.Invoke(dbCmd);
            dbCmd.CommandText = sql;

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

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

            return(dbCmd.ConvertToListAsync <T>(OrmLiteConfig.DialectProvider.ToSelectStatement(typeof(T), null, sql), token));
        }
        internal static Task<List<T>> WhereAsync<T>(this IDbCommand dbCmd, string name, object value, CancellationToken token)
        {
            if (!dbCmd.CanReuseParam<T>(name))
                dbCmd.SetFilter<T>(name, value);

            ((IDbDataParameter)dbCmd.Parameters[0]).Value = value;

            return 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(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 <List <T> > SqlListAsync <T>(this IDbCommand dbCmd, string sql, object anonType, CancellationToken token)
        {
            if (anonType != null)
            {
                dbCmd.SetParameters <T>(anonType, excludeDefaults: false);
            }
            dbCmd.CommandText = sql;

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

            return(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(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 = OrmLiteConfig.DialectProvider.ToSelectStatement(typeof(T), null, sql);

            return(OrmLiteReadExtensions.IsScalar <T>()
                ? dbCmd.ColumnAsync <T>(null, token)
                : dbCmd.ConvertToListAsync <T>(null, 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(OrmLiteReadExtensions.IsScalar <T>()
                ? dbCmd.ColumnAsync <T>(null, token)
                : dbCmd.ConvertToListAsync <T>(null, token));
        }
        internal static Task <List <TOutputModel> > SqlProcedureFmtAsync <TOutputModel>(this IDbCommand dbCmd, CancellationToken token,
                                                                                        object fromObjWithProperties,
                                                                                        string sqlFilter,
                                                                                        params object[] filterParams)
        {
            var modelType = typeof(TOutputModel);

            string sql = dbCmd.GetDialectProvider().ToSelectFromProcedureStatement(
                fromObjWithProperties, modelType, sqlFilter, filterParams);

            return(dbCmd.ConvertToListAsync <TOutputModel>(sql, 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(OrmLiteReadExtensions.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 = OrmLiteConfig.DialectProvider.ToSelectStatement(typeof(T), null, sql);

            return(OrmLiteReadExtensions.IsScalar <T>()
                ? dbCmd.ColumnAsync <T>(null, token)
                : dbCmd.ConvertToListAsync <T>(null, token));
        }
 public static Task <List <T> > ConvertToListAsync <T>(this IDbCommand dbCmd)
 {
     return(dbCmd.ConvertToListAsync <T>(null, default(CancellationToken)));
 }
예제 #17
0
 internal static Task <List <T> > SelectAsync <T>(this IDbCommand dbCmd, string sql, Dictionary <string, object> dict, CancellationToken token)
 {
     dbCmd.SetParameters(dict, excludeDefaults: false, sql: ref sql).CommandText = dbCmd.GetDialectProvider().ToSelectStatement(typeof(T), sql);
     return(dbCmd.ConvertToListAsync <T>(null, token));
 }
 internal static Task <List <T> > SqlColumnAsync <T>(this IDbCommand dbCmd, string sql, IEnumerable <IDbDataParameter> sqlParams, CancellationToken token)
 {
     dbCmd.SetParameters(sqlParams).CommandText = sql;
     return(dbCmd.ConvertToListAsync <T>(null, token));
 }
 internal static Task <List <T> > SqlColumnAsync <T>(this IDbCommand dbCmd, string sql, Dictionary <string, object> dict, CancellationToken token)
 {
     dbCmd.SetParameters(dict, excludeDefaults: false).CommandText = sql;
     return(dbCmd.ConvertToListAsync <T>(null, token));
 }
 internal static Task <List <T> > SelectFmtAsync <T>(this IDbCommand dbCmd, CancellationToken token, string sqlFilter, params object[] filterParams)
 {
     return(dbCmd.ConvertToListAsync <T>(
                OrmLiteConfig.DialectProvider.ToSelectStatement(typeof(T), null, sqlFilter, filterParams), token));
 }
 internal static Task <List <T> > SelectAsync <T>(this IDbCommand dbCmd, string sql, IEnumerable <IDbDataParameter> sqlParams, CancellationToken token)
 {
     dbCmd.SetParameters(sqlParams).CommandText = dbCmd.GetDialectProvider().ToSelectStatement(typeof(T), sql);
     return(dbCmd.ConvertToListAsync <T>(null, token));
 }
 public static Task <IList> ConvertToListAsync(this IDbCommand dbCmd, Type refType)
 {
     return(dbCmd.ConvertToListAsync(refType, null, default(CancellationToken)));
 }
        internal static Task <List <T> > SelectNonDefaultsAsync <T>(this IDbCommand dbCmd, object filter, CancellationToken token)
        {
            dbCmd.SetFilters <T>(filter, excludeDefaults: true);

            return(dbCmd.ConvertToListAsync <T>(null, token));
        }
예제 #24
0
 internal static Task <List <T> > WhereAsync <T>(this IDbCommand dbCmd, string name, object value, CancellationToken token)
 {
     dbCmd.SetFilter <T>(name, value);
     return(dbCmd.ConvertToListAsync <T>(null, token));
 }
예제 #25
0
 internal static Task <List <T> > SqlColumnAsync <T>(this IDbCommand dbCmd, string sql, object anonType, CancellationToken token)
 {
     dbCmd.SetParameters(anonType.ToObjectDictionary(), excludeDefaults: false, sql: ref sql).CommandText = sql;
     return(dbCmd.ConvertToListAsync <T>(null, token));
 }
        internal static Task <List <T> > WhereAsync <T>(this IDbCommand dbCmd, object anonType, CancellationToken token)
        {
            dbCmd.SetFilters <T>(anonType);

            return(dbCmd.ConvertToListAsync <T>(null, token));
        }