UnitOfWork.cs 892 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using DW5S.Entity;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace DW5S.Repostory
  8. {
  9. public interface IUnitOfWork : IAsyncDisposable
  10. {
  11. IRepository<TEntity> Of<TEntity>() where TEntity : BaseEntity;
  12. Task<int> SaveAsync();
  13. }
  14. public class UnitOfWork : IUnitOfWork
  15. {
  16. private readonly OracleContext ctx;
  17. public IRepository<TEntity> Of<TEntity>() where TEntity : BaseEntity
  18. {
  19. throw new NotImplementedException();
  20. }
  21. public UnitOfWork(OracleContext ctx)
  22. {
  23. this.ctx = ctx;
  24. }
  25. public async Task<int> SaveAsync()
  26. {
  27. return await ctx.SaveChangesAsync();
  28. }
  29. public async ValueTask DisposeAsync()
  30. {
  31. await ctx.DisposeAsync();
  32. }
  33. }
  34. }