1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using DW5S.Entity;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DW5S.Repostory
- {
- public interface IUnitOfWork : IAsyncDisposable
- {
- IRepository<TEntity> Of<TEntity>() where TEntity : BaseEntity;
- Task<int> SaveAsync();
- }
- public class UnitOfWork : IUnitOfWork
- {
- private readonly OracleContext ctx;
- public IRepository<TEntity> Of<TEntity>() where TEntity : BaseEntity
- {
- var reps = IocContainer.GetService<IRepository<TEntity>>();
- return reps;
- }
- public UnitOfWork(OracleContext ctx)
- {
- this.ctx = ctx;
- }
- public async Task<int> SaveAsync()
- {
- return await ctx.SaveChangesAsync();
- }
- public async ValueTask DisposeAsync()
- {
- await ctx.DisposeAsync();
- }
- }
- }
|