RepositoryExtension.cs 1.0 KB

1234567891011121314151617181920212223242526272829
  1. using Furion;
  2. using SqlSugar;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Linq.Expressions;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace Admin.NET.Core.Extension
  10. {
  11. public static class RepositoryExtension
  12. {
  13. /// <summary>
  14. /// 根据已有实体假删除 _rep.Context.Updateable(entity).FakeDelete().ExecuteCommandAsync();
  15. /// </summary>
  16. /// <typeparam name="T"></typeparam>
  17. /// <param name="updateable"></param>
  18. /// <returns></returns>
  19. public static IUpdateable<T> FakeDelete<T>(this IUpdateable<T> updateable) where T : EntityBase, new()
  20. {
  21. return updateable.ReSetValue(x => { x.IsDelete = true; })
  22. .IgnoreColumns(ignoreAllNullColumns: true)
  23. .EnableDiffLogEvent() //记录差异日志
  24. .UpdateColumns(x => new { x.IsDelete, x.UpdateTime, x.UpdateUserId }); //允许更新的字段, AOP拦截会自动设置UpdateTime,UpdateUserId
  25. }
  26. }
  27. }