/// <summary> /// Attach list of entities /// </summary> /// <param name="entities"></param> public virtual void Attach(ICollection <TEntity> entities) { foreach (var entity in entities) { if (context.Entry(entity).State == EntityState.Detached) { context.Set <TEntity>().Attach(entity); } } }
/// <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; }