Example #1
0
        /// <summary>
        /// 更新字段(主键)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="columns"></param>
        /// <param name="whereExpression"></param>
        /// <param name="locked">是否锁</param>
        /// <returns></returns>
        public bool Update <T>(T t, Expression <Func <T, object> > columns, bool locked = false) where T : class, new()
        {
            try {
                IUpdateable <T> updateable = dal.SqlSugarDb
                                             .Updateable <T>(t)
                                             .UpdateColumns(columns);

                if (locked)
                {
                    updateable = updateable.With(SqlWith.UpdLock);
                }

                bool result = updateable.ExecuteCommandHasChange();

                return(result);
            } catch (Exception) {
                throw;
            }
        }