using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; using GreenTree.Nachtragsmanagement.Core; using GreenTree.Nachtragsmanagement.Data; namespace GreenTree.Nachtragsmanagement.Services.DbContext { public class DbContextService : IDbContextService { #region Fields /// /// Current database context /// private readonly IDbContext _dbContext; #endregion #region Ctor /// /// Initializes a new instance of the DbContextService class /// public DbContextService(IDbContext iDbContext) { _dbContext = iDbContext; } #endregion #region Services /// /// Checks if a DbSet exists in the curent DbContext /// /// The entity type of the DbSet. public bool DbSetExists() where TEntity : BaseEntity { var dbSet = _dbContext.Get(); return dbSet != null; } /// /// Get the DbSet of the corresponding Entity type /// /// The entity type of the DbSet. public IDbSet GetDbSet() where TEntity : BaseEntity { var dbSet = _dbContext.Get(); return dbSet; } /// /// Gets the current DbContext /// public AppendixObjectContext GetDbContext() { return (AppendixObjectContext)_dbContext; } #endregion } }