예제 #1
0
        /// <inheritdoc />
        public Task Add(TRoot[] instances)
        {
            Argument.NotNull(instances, nameof(instances));

            this.Logger.Verbose($"Adding {instances.Count()} items of type {typeof(TRoot)} using {this.GetType().Name}:{_context.GetType().Name}.");

            return(_context.Add(instances));
        }
예제 #2
0
 public int Add(PO po)
 {
     this.EnsureParameterNotNull(po, () => po);
     using (IEntityContext entityContext = CreateEntityContext(false))
     {
         entityContext.Add <PO>(po);
     }
     return(po.Id);
 }
예제 #3
0
        public int AddWithContext(IEntityContext entityContext, PO po)
        {
            this.EnsureParameterNotNull(entityContext, () => entityContext);
            this.EnsureParameterNotNull(po, () => po);

            entityContext.Add <PO>(po);

            return(po.Id);
        }
        public void AddOperationLogWithContext(IEntityContext entityContext, int key, EnumOperationLogType type, EnumOperationLogAction action, object objOld, object objNew, string sOperator)
        {
            ObjectComparer objCompare = this.GetResComparer();

            COperationLogPO log = new COperationLogPO();

            log.Type         = (byte)type;
            log.Action       = (byte)action;
            log.CreateTime   = DateTime.Now;
            log.DataInfo     = objCompare.GetDifference(objOld, objNew);
            log.DataId       = key;
            log.OperatorName = sOperator;
            log.TypeName     = type.ToString();

            entityContext.Add(log);
        }
예제 #5
0
        public void Save(TEntity entity)
        {
            var currentUserId = entity.ModifiedByUserId = CurrentUserProvider.GetCurrentUser()?.Id;

            entity.ModifiedAt       = DateTime.UtcNow;
            entity.ModifiedByUserId = currentUserId;

            if (entity.IsNew())
            {
                entity.CreatedAt       = DateTime.UtcNow;
                entity.CreatedByUserId = currentUserId;
                _entityContext.Add(entity);
            }
            else
            {
                _entityContext.Attach(entity);
            }
        }