public void Update(T entity) { DbContext.Entry(entity) .State = EntityState.Modified; if (EntityTypeBuilderExtensions.HasShadowField(typeof(T))) { UpdateShadowProperties(entity); } }
public void Add(T entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } // fill shadow property if (EntityTypeBuilderExtensions.HasShadowField(typeof(T))) { InsertShadowProperties(entity); } _dbSet.Add(entity); }
public void Add(IEnumerable <T> entities) { var enumerable = entities.ToList(); if (entities == null || !enumerable.Any()) { throw new ArgumentNullException(nameof(entities)); } // fill shadow property if (EntityTypeBuilderExtensions.HasShadowField(typeof(T))) { foreach (var entity in enumerable) { InsertShadowProperties(entity); } } _dbSet.AddRange(enumerable); }