Advertisement
Shuva_Dev

UnitOfWork

Jul 4th, 2024
862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using Blog.Domain;
  2. using Blog.Domain.RepositoryContracts;
  3. using Microsoft.EntityFrameworkCore;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Runtime.CompilerServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10.  
  11. namespace Blog.Infrastructure.UnitOfWorks
  12. {
  13.     public abstract class UnitOfWork : IUnitOfWork
  14.     {
  15.         private readonly DbContext _dbContext;
  16.         //protected IAdoNetUtility AdoNetUtility { get; private set; }
  17.  
  18.         public UnitOfWork(DbContext dbContext)
  19.         {
  20.             _dbContext = dbContext;
  21.             //AdoNetUtility = new AdoNetUtility(_dbContext.Database.GetDbConnection());
  22.         }
  23.  
  24.         public void Dispose() => _dbContext?.Dispose();
  25.         public ValueTask DisposeAsync() => _dbContext.DisposeAsync();
  26.         public void Save() => _dbContext?.SaveChanges();
  27.         public async Task SaveAsync() => await _dbContext.SaveChangesAsync();
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement