Ejemplo n.º 1
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="lstValue">强制设置值</param>
        ///  <param name="optimisticConcurrency">是否并发控制</param>
        /// <returns></returns>
        public virtual int Update(ValueSetList lstValue, bool optimisticConcurrency)
        {
            DataAccessSetBase dal = GetBaseDataAccess();

            foreach (EntityPropertyInfo epPk in dal.EntityInfo.PrimaryProperty)
            {
                object id = epPk.GetValue(this);
                if (DefaultType.IsDefaultValue(id))
                {
                    throw new Exception("主键:" + epPk.PropertyName + "的值不能为空");
                }
            }
            return(dal.Update(this, null, lstValue, optimisticConcurrency));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 填充版本控制的信息
        /// </summary>
        /// <param name="where"></param>
        /// <param name="where"></param>
        /// <param name="info"></param>
        /// <param name="list"></param>
        /// <param name="curValue"></param>
        protected internal void FillWhereConcurrency(StringBuilder where,
                                                     EntityPropertyInfo info, ParamList list, object curValue, ref int index)
        {
            string paramValW = EntityInfo.DBInfo.CurrentDbAdapter.FormatValueName(DataAccessCommon.FormatParam(info.ParamName, index));
            string paramKeyW = EntityInfo.DBInfo.CurrentDbAdapter.FormatParamKeyName(DataAccessCommon.FormatParam(info.ParamName, index));

            index++;
            if (DefaultType.IsDefaultValue(curValue))
            {
                throw new Exception("版本控制字段:" + info.PropertyName + " 必须有当前版本值");
            }
            where.Append(" and ");
            where.Append(EntityInfo.DBInfo.CurrentDbAdapter.FormatParam(info.ParamName));
            where.Append("=");
            where.Append(paramValW);
            list.AddNew(paramKeyW, info.SqlType, curValue);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 并发删除
        /// </summary>
        /// <param name="optimisticConcurrency">是否并发控制</param>
        /// <returns></returns>
        public virtual int Delete(bool optimisticConcurrency)
        {
            DataAccessSetBase dal      = GetBaseDataAccess();
            ScopeList         lstScope = new ScopeList();

            foreach (EntityPropertyInfo pInfo in dal.EntityInfo.PrimaryProperty)
            {
                object id = pInfo.GetValue(this);
                if (DefaultType.IsDefaultValue(id))
                {
                    throw new Exception("主键:" + pInfo.PropertyName + "的值不能为空");
                }
                lstScope.AddEqual(pInfo.PropertyName, id);
            }


            return(dal.Delete(this, lstScope, optimisticConcurrency));
        }