Esempio n. 1
0
        /// <summary>
        /// Adds the or update bulk.
        /// </summary>
        /// <param name="batchSize">Size of the batch.</param>
        /// <param name="entities">The entities.</param>
        public virtual void AddOrUpdateBulk(ushort batchSize = 50000, params TE[] entities)
        {
            entities.ForEach(x =>
            {
                x.CreatedAt = DateTime.Now;
                x.CreatedBy = DbContext.UserId;

                x.LastModifiedAt = DateTime.Now;
                x.LastModifiedBy = DbContext.UserId;
                x.ClientIp       = DbContext.ClientIp;
            });

            DbContext.BulkMerge(entities, operation =>
            {
                operation.BatchSize = batchSize;
                operation.IgnoreOnMergeUpdateExpression = entity => new { entity.CreatedAt, entity.CreatedBy };
            });
        }