예제 #1
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="db"></param>
        /// <param name="whereConditions"></param>
        /// <param name="transaction"></param>
        /// <param name="commandTimeout"></param>
        public static int DeleteListByBulk <T>(this IDbConnection db, object whereConditions, IDbTransaction transaction = null, int?commandTimeout = null) where T : new()
        {
            var obj = QueryableBuilder.GetListByBulk <T>(whereConditions);
            var sql = $"DELETE FROM {obj.TableName}{obj.Where};";

            return(db.Execute(sql, whereConditions, transaction, commandTimeout, CommandType.Text));
        }
예제 #2
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="db"></param>
        /// <param name="whereConditions"></param>
        /// <param name="transaction"></param>
        /// <param name="commandTimeout"></param>
        /// <returns></returns>
        public static IQuery <T> GetListByBulk <T>(this SqlConnection db, object whereConditions, SqlTransaction transaction = null, int?commandTimeout = null)
        {
            var obj = QueryableBuilder.GetListByBulk <T>(whereConditions);

            obj.Db              = db;
            obj.Transaction     = transaction;
            obj.CommandTimeout  = commandTimeout;
            obj.WhereConditions = whereConditions;
            return(obj);
        }
예제 #3
0
        /// <summary>
        /// 基于字段匹配集合查询数据(获取首条FirstOrDefault,排序OrderBy)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="db"></param>
        /// <param name="whereConditions"></param>
        /// <param name="selectColumns"></param>
        /// <param name="transaction"></param>
        /// <param name="commandTimeout"></param>
        /// <returns></returns>
        public static IQuery <T> GetListByBulk <T>(this IDbConnection db, object whereConditions, Expression <Func <T, object> > selectColumns, IDbTransaction transaction = null, int?commandTimeout = null) where T : new()
        {
            var obj = QueryableBuilder.GetListByBulk(whereConditions, selectColumns);

            obj.Db              = db;
            obj.Transaction     = transaction;
            obj.CommandTimeout  = commandTimeout;
            obj.WhereConditions = whereConditions;
            return(obj);
        }