Beispiel #1
0
        /// <summary>
        ///  删除
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="entity"></param>
        /// <returns></returns>
        public void Delete <TEntity>(TEntity entity)
            where TEntity : Entity
        {
            Check.Require(!EntityCache.IsReadOnly <TEntity>(), string.Concat("Entity(", EntityCache.GetTableName <TEntity>(), ") is readonly!"));

            WhereClip where = DataUtils.GetPrimaryKeyWhere(entity);

            Check.Require(!WhereClip.IsNullOrEmpty(where), "entity must have the primarykey!");
            Delete <TEntity>(where);
            //2015-08-20注释
            //Delete<TEntity>(entity, where);
        }
Beispiel #2
0
        /// <summary>
        /// 更新全部字段
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="entity"></param>
        public void UpdateAll <TEntity>(TEntity entity)
            where TEntity : Entity
        {
            if (entity == null)
            {
                return;
            }

            WhereClip where = DataUtils.GetPrimaryKeyWhere(entity);

            Check.Require(!WhereClip.IsNullOrEmpty(where), "entity must have the primarykey!");

            UpdateAll <TEntity>(entity, where);
        }
Beispiel #3
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="entity"></param>
        public void Update <TEntity>(TEntity entity)
            where TEntity : Entity
        {
            if (entity.GetModifyFields().Count == 0)
            {
                return;
            }

            WhereClip where = DataUtils.GetPrimaryKeyWhere(entity);

            Check.Require(!WhereClip.IsNullOrEmpty(where), "entity must have the primarykey!");

            Update <TEntity>(entity, where);
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="entity"></param>
        public void Update <TEntity>(TEntity entity)
            where TEntity : Entity
        {
            if (!entity.IsModify())
            {
                return;
            }

            var where = DataUtils.GetPrimaryKeyWhere(entity);

            Check.Require(!WhereClip.IsNullOrEmpty(where), "entity must have the primarykey!");

            Update <TEntity>(entity, where);
        }
Beispiel #5
0
        /// <summary>
        ///  删除
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="pkValues"></param>
        /// <returns></returns>
        public void Delete <TEntity>(params Guid[] pkValues)
            where TEntity : Entity
        {
            Check.Require(!EntityCache.IsReadOnly <TEntity>(), string.Concat("Entity(", EntityCache.GetTableName <TEntity>(), ") is readonly!"));

            batchcmd.Process(cmdCreator.CreateDeleteCommand(EntityCache.GetTableName <TEntity>(), DataUtils.GetPrimaryKeyWhere <TEntity>(pkValues)));
        }