FreeSqlRepositoryExtensions.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using ZhonTai.Plate.Admin.Domain;
  2. using System;
  3. using System.Linq.Expressions;
  4. using ZhonTai.Common.Domain.Repositories;
  5. public static class FreeSqlDbContextExtensions
  6. {
  7. /// <summary>
  8. /// 返回默认仓库类
  9. /// </summary>
  10. /// <typeparam name="TEntity"></typeparam>
  11. /// <typeparam name="TKey"></typeparam>
  12. /// <param name="that"></param>
  13. /// <param name="filter">数据过滤 + 验证</param>
  14. /// <returns></returns>
  15. public static IRepositoryBase<TEntity, TKey> GetRepositoryBase<TEntity, TKey>(this IFreeSql that, Expression<Func<TEntity, bool>> filter = null) where TEntity : class, new()
  16. {
  17. return new DefaultRepositoryBase<TEntity, TKey>(that, filter);
  18. }
  19. /// <summary>
  20. /// 返回默认仓库类,适用联合主键的仓储类
  21. /// </summary>
  22. /// <typeparam name="TEntity"></typeparam>
  23. /// <param name="that"></param>
  24. /// <param name="filter">数据过滤 + 验证</param>
  25. /// <returns></returns>
  26. public static IRepositoryBase<TEntity, long> GetRepositoryBase<TEntity>(this IFreeSql that, Expression<Func<TEntity, bool>> filter = null) where TEntity : class, new()
  27. {
  28. return new DefaultRepositoryBase<TEntity, long>(that, filter);
  29. }
  30. public static IRepositoryBase<TEntity, long> GetRepositoryBase<TEntity>(this IFreeSql that, MyUnitOfWorkManager muowManger) where TEntity : class, new()
  31. {
  32. return new DefaultRepositoryBase<TEntity, long>(that, muowManger);
  33. }
  34. }