Пример #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));
        }
Пример #2
0
        /// <summary>
        /// 更新
        /// 注意:rowObj为T类型将更新该实体的非主键所有列,如果rowObj类型为匿名类将更新指定列
        /// 使用说明:sqlSugar.Update《T》(rowObj,whereObj);
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="FiledType">主键类型</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));
        }
        /// <summary>
        /// 更新是否查看推送状态
        /// </summary>
        /// <param name="contentModel"></param>
        /// <returns></returns>
        public bool UpdateIsReadStatus(U_Content contentModel, string invalidusers = "")
        {
            using (SqlSugar.SqlSugarClient _dbMsSql = SugarDao.SugarDao_MsSql.GetInstance())
            {
                bool result = false;
                try
                {
                    foreach (var item in contentModel.PushObject)
                    {
                        if (!invalidusers.Contains(item.UserID))
                        {
                            result = _dbMsSql.Update <Business_WeChatPushDetail_Information>(new { ISRead = "1" }, i => i.Business_WeChatPushVguid == contentModel.VGUID && i.PushObject == item.UserID);
                        }
                    }
                }
                catch (Exception exp)
                {
                    LogManager.WriteLog(LogFile.Error, "更新推送是否查看:" + exp.ToString());
                }

                return(result);
            }
        }