/// <summary>
        /// 物理删除
        /// </summary>
        /// <param name="info"></param>
        /// <param name="logonInfo"></param>
        /// <returns></returns>
        public ResultView Remove(T info, TokenLogonInfo logonInfo)
        {
            if (info == null)
            {
                throw ApiException.EmptyData("无法找到要删除的数据");
            }
            string id = info.Id.ToString();

            _logger.LogTrace($"物理删除 ==> 类型为:[{typeof(T).FullName}]\t删除ID为:[{id}]");
            try
            {
                // 判断对应数据是否可以删除.
                DeleteRemoveCheck(info);
                OnDeleteRemoveCheck?.Invoke(info, logonInfo);
                RemoveCheck(info);
                OnRemoveCheck?.Invoke(info, logonInfo);
                // 物理删除的前置操作
                DeleteRemoving(info, logonInfo);
                Removing(info, logonInfo);
                // 物理删除时的前置事件处理
                OnRemoving?.Invoke(info, logonInfo);
                // 持久化数据
                _Dal.RemoveObject(info);
                // 物理删除的后置处理
                Removed(info, logonInfo);
                DeleteRemoved(info, logonInfo);
                // 物理删除时的后置事件处理
                OnRemoved?.Invoke(info, logonInfo);
                // 返回保存结果
                return(ResultView.Success(info.Id.ToString()));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"物理删除异常 ==> 类型为:[{typeof(T).FullName}]\t删除ID为:[{id}]]\r\n删除对象为:[{info.ToJson()}]");
                throw;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Removes the object without effects.
 /// </summary>
 protected virtual void Remove()
 {
     OnRemoving?.Invoke(this, this);
 }