/// <summary>
        /// Counts the number of rows that match the given condition.
        /// </summary>
        /// <param name="whereExpr">The where condition to use for this query.</param>
        /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
        /// <returns>The number of rows that match the given condition.</returns>
        public override int RecordCount(Expression <Func <T, bool> > whereExpr, int commandTimeout = 30)
        {
            WhereConditionData <T> data = Queries.Compile(whereExpr);
            int count = RecordCount(data.WhereCondition, data.Param, commandTimeout);

            return(count);
        }
        /// <summary>
        /// Selects the rows that match the given condition.
        /// </summary>
        /// <param name="columnFilter">The type whose properties will filter the result.</param>
        /// <param name="whereExpr">The where condition to use for this query.</param>
        /// <param name="buffered">Whether to buffer the results in memory.</param>
        /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
        /// <returns>The rows that match the given condition.</returns>
        public override IEnumerable <T> GetList(Type columnFilter, Expression <Func <T, bool> > whereExpr, bool buffered = true, int commandTimeout = 30)
        {
            WhereConditionData <T> data = Queries.Compile(whereExpr);
            IEnumerable <T>        keys = GetList(columnFilter, data.WhereCondition, data.Param, buffered, commandTimeout);

            return(keys);
        }
        /// <summary>
        /// Selects the rows with the given keys.
        /// </summary>
        /// <typeparam name="KeyType">The key type.</typeparam>
        /// <param name="whereExpr">The where condition to use for this query.</param>
        /// <param name="buffered">Whether to buffer the results in memory.</param>
        /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
        /// <returns>The keys that match the given condition.</returns>
        public override IEnumerable <KeyType> GetKeys <KeyType>(Expression <Func <T, bool> > whereExpr, bool buffered = true, int commandTimeout = 30)
        {
            WhereConditionData <T> data = Queries.Compile(whereExpr);
            IEnumerable <KeyType>  keys = GetKeys <KeyType>(data.WhereCondition, data.Param, buffered, commandTimeout);

            return(keys);
        }
        /// <summary>
        /// Selects the rows that match the given condition.
        /// </summary>
        /// <param name="limit">The maximum number of rows.</param>
        /// <param name="columnFilter">The type whose properties will filter the result.</param>
        /// <param name="whereExpr">The where condition to use for this query.</param>
        /// <param name="buffered">Whether to buffer the results in memory.</param>
        /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
        /// <returns>The rows that match the given condition.</returns>
        public override IEnumerable <T> GetDistinctLimit(int limit, Type columnFilter, Expression <Func <T, bool> > whereExpr, bool buffered = true, int commandTimeout = 30)
        {
            WhereConditionData <T> data = Queries.Compile(whereExpr);
            IEnumerable <T>        list = GetDistinctLimit(limit, columnFilter, data.WhereCondition, data.Param, buffered, commandTimeout);

            return(list);
        }
Beispiel #5
0
        /// <summary>
        /// Selects the rows that match the given condition.
        /// </summary>
        /// <typeparam name="T">The table type.</typeparam>
        /// <param name="connection">The connection to query on.</param>
        /// <param name="columnFilter">The type whose properties will filter the result.</param>
        /// <param name="whereExpr">The where condition to use for this query.</param>
        /// <param name="transaction">The transaction to use for this query.</param>
        /// <param name="buffered">Whether to buffer the results in memory.</param>
        /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
        /// <returns>The rows that match the given condition.</returns>
        public static IEnumerable <T> GetDistinct <T>(this IDbConnection connection, Type columnFilter, Expression <Func <T, bool> > whereExpr, IDbTransaction transaction = null, bool buffered = true, int commandTimeout = 30)
            where T : class
        {
            ISqlQueries <T>        queries = ExtraCrud.Queries <T>();
            WhereConditionData <T> data    = queries.Compile(whereExpr);
            IEnumerable <T>        list    = queries.GetDistinct(connection, columnFilter, data.WhereCondition, data.Param, transaction, buffered, commandTimeout);

            return(list);
        }
Beispiel #6
0
        /// <summary>
        /// Deletes the rows that match the given condition.
        /// </summary>
        /// <typeparam name="T">The table type.</typeparam>
        /// <param name="connection">The connection to query on.</param>
        /// <param name="whereExpr">The where condition to use for this query.</param>
        /// <param name="transaction">The transaction to use for this query.</param>
        /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
        /// <returns>The number of deleted rows.</returns>
        public static int DeleteList <T>(this IDbConnection connection, Expression <Func <T, bool> > whereExpr, IDbTransaction transaction = null, int commandTimeout = 30)
            where T : class
        {
            ISqlQueries <T>        queries = ExtraCrud.Queries <T>();
            WhereConditionData <T> data    = queries.Compile(whereExpr);
            int count = queries.DeleteList(connection, data.WhereCondition, data.Param, transaction, commandTimeout);

            return(count);
        }
Beispiel #7
0
        /// <summary>
        /// Selects the rows with the given keys.
        /// </summary>
        /// <typeparam name="T">The table type.</typeparam>
        /// <typeparam name="KeyType">The key type.</typeparam>
        /// <param name="connection">The connection to query on.</param>
        /// <param name="whereExpr">The where condition to use for this query.</param>
        /// <param name="transaction">The transaction to use for this query.</param>
        /// <param name="buffered">Whether to buffer the results in memory.</param>
        /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
        /// <returns>The keys that match the given condition.</returns>
        public static IEnumerable <KeyType> GetKeys <T, KeyType>(this IDbConnection connection, Expression <Func <T, bool> > whereExpr, IDbTransaction transaction = null, bool buffered = true, int commandTimeout = 30)
            where T : class
        {
            ISqlQueries <T>        queries = ExtraCrud.Queries <T>();
            WhereConditionData <T> data    = queries.Compile(whereExpr);
            IEnumerable <object>   keys    = queries.GetKeysKeys(connection, data.WhereCondition, data.Param, transaction, buffered, commandTimeout);

            if (typeof(KeyType) == typeof(long))
            {
                if (keys.Any())
                {
                    Type type = keys.First().GetType();
                    if (type == typeof(int))
                    {
                        keys = keys.Select(k => (object)(long)(int)k);
                    }
                }
            }
            IEnumerable <KeyType> castedKeys = keys.Select(k => (KeyType)k);

            return(castedKeys);
        }