Beispiel #1
0
        /// <summary>
        /// 更新
        /// 注意:rowObj为T类型将更新该实体的非主键所有列,如果rowObj类型为匿名类将更新指定列
        /// 使用说明:sqlSugar.Update《T》(rowObj,whereObj);
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="rowObj">new T(){name="张三",sex="男"}或者new {name="张三",sex="男"}</param>
        /// <param name="expression">it.id=100</param>
        /// <returns></returns>
        public bool Update <T>(object rowObj, System.Linq.Expressions.Expression <Func <T, bool> > expression) where T : class
        {
            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.Update <T>(rowObj, expression));
                }, tasks, i);
            }
            Task.WaitAll(tasks);
            return(tasks.Any(it => it.Result));
        }
Beispiel #2
0
        /// <summary>
        /// 更新
        /// 注意:rowObj为T类型将更新该实体的非主键所有列,如果rowObj类型为匿名类将更新指定列
        /// 使用说明:sqlSugar.Update《T》(rowObj,whereObj);
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="rowObj">new T(){name="张三",sex="男"}或者new {name="张三",sex="男"}</param>
        /// <param name="whereIn">new int[]{1,2,3}</param>
        /// <returns></returns>
        public bool Update <T, FiledType>(object rowObj, params FiledType[] whereIn) where T : class
        {
            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.Update <T, FiledType>(rowObj, whereIn));
                }, tasks, i);
            }
            Task.WaitAll(tasks);
            return(tasks.Any(it => it.Result));
        }