示例#1
0
        /// <summary>
        /// 删除,根据表达式
        /// 使用说明:
        /// Delete《T》(it=>it.id=100) 或者Delete《T》(3)
        /// </summary>
        /// <param name="expression">筛选表达式</param>
        public bool Delete <T>(System.Linq.Expressions.Expression <Func <T, bool> > expression)
        {
            var tasks = new Task <bool> [configList.Count];

            for (int i = 0; i < tasks.Length; i++)
            {
                CloudPubMethod.TaskFactory <bool>(ti =>
                {
                    var connName = configList[ti].ConnectionString;
                    var db       = new SqlSugarClient(connName);
                    SettingConnection(db);
                    return(db.Delete <T>(expression));
                }, tasks, i);
            }
            Task.WaitAll(tasks);
            return(tasks.Any(it => it.Result));
        }
示例#2
0
        /// <summary>
        /// 批量删除
        /// 注意:whereIn 主键集合
        /// 使用说明:Delete《T》(new int[]{1,2,3}) 或者  Delete《T》(3)
        /// </summary>
        /// <param name="whereIn"> delete ids </param>
        public bool Delete <T, FiledType>(params FiledType[] whereIn)
        {
            var tasks = new Task <bool> [configList.Count];

            for (int i = 0; i < tasks.Length; i++)
            {
                CloudPubMethod.TaskFactory <bool>(ti =>
                {
                    var connName = configList[ti].ConnectionString;
                    var db       = new SqlSugarClient(connName);
                    SettingConnection(db);
                    return(db.Delete <T, FiledType>(whereIn));
                }, tasks, i);
            }
            Task.WaitAll(tasks);
            return(tasks.Any(it => it.Result));
        }