示例#1
0
        /// <summary>
        /// Insert a new entity
        /// </summary>
        /// <typeparam name="TEntity">Entity type</typeparam>
        /// <param name="entity">Entity</param>
        /// <returns>Entity</returns>
        public virtual TEntity InsertEntity <TEntity>(TEntity entity) where TEntity : BaseEntity
        {
            using (var currentConnection = new NopDataConnection())
            {
                entity.Id = currentConnection.InsertWithInt32Identity(entity);

                return(entity);
            }
        }
示例#2
0
        /// <summary>
        /// Insert entity
        /// </summary>
        /// <param name="entity">Entity</param>
        public virtual void Insert(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            using (var _dataConnection = new NopDataConnection())
            {
                entity.Id = _dataConnection.InsertWithInt32Identity(entity);
            }
        }