Beispiel #1
0
 public void Update(T entity)
 {
     DbContext.Entry(entity)
     .State = EntityState.Modified;
     if (EntityTypeBuilderExtensions.HasShadowField(typeof(T)))
     {
         UpdateShadowProperties(entity);
     }
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }