예제 #1
0
        public async Task <T> AddAsync(T entity)
        {
            await _dbContext.Set <T>().AddAsync(entity);

            await _dbContext.SaveChangesAsync();

            return(entity);
        }
예제 #2
0
        public async Task <T> AddAsync(T entity)
        {
            await _dbContext.Set <T>().AddAsync(entity);

            //this makes sure the code is executed and databse will be updated
            await _dbContext.SaveChangesAsync();

            return(entity);
        }
예제 #3
0
        public virtual async Task <T> AddAsync(T entity)
        {
            _dbContext.Set <T>().Add(entity);
            await _dbContext.SaveChangesAsync();

            // it will automatically update the entity, like set to null, add id identity if
            // successful added into database
            return(entity);
        }
예제 #4
0
        public async Task <T> AddAsync(T entity)
        {
            // Movie
            // Id PK,Identity
            // Title ="ABC", Revenue =1223321
            _dbContext.Set <T>().Add(entity);
            await _dbContext.SaveChangesAsync();

            return(entity);
        }
예제 #5
0
        public async Task <T> AddAsync(T entity)
        {
            //this is the disconnected way: using stateless protocol.
            //just tell EF we want to update the entity.
            await _dbContext.Set <T>().AddAsync(entity);

            await _dbContext.SaveChangesAsync();

            return(entity);
        }
예제 #6
0
        public async Task <T> AddAsync(T entity)
        {
            // Movie
            // Id PK,Identity
            // Title ="ABC", Revenue =1223321
            // Add method, important, use await save method after this method.
            _dbContext.Set <T>().Add(entity);
            await _dbContext.SaveChangesAsync();

            return(entity);
        }