/// <summary> /// Dispose object based on flag value /// </summary> /// <param name="disposing">Flag that indicates if disposing is in progress</param> protected virtual void Dispose(bool disposing) { if (disposing && context != null) { context.Dispose(); context = null; } }
/// <summary> /// Constructor that accepts database context /// </summary> /// <param name="dbContext">Database context</param> public GenericRepository(GDPRiSDBContext dbContext) { context = dbContext; dbSet = context.Set <TEntity>(); context.Configuration.ProxyCreationEnabled = false; context.Configuration.LazyLoadingEnabled = false; context.Configuration.ValidateOnSaveEnabled = false; context.Configuration.AutoDetectChangesEnabled = false; // Get the ObjectContext related to this DbContext var objectContext = (context as IObjectContextAdapter).ObjectContext; // Sets the command timeout for all the commands objectContext.CommandTimeout = 1800; }