예제 #1
0
        public override int Delete()
        {
            var mapping      = DataEntityMapping.GetTableMapping(typeof(T));
            var queryCommand = _context.Database.QueryDelete(_context, mapping, _query);

            return(_context.ExecuteNonQuery(queryCommand.Command, _level));
        }
예제 #2
0
        public override async Task <int> DeleteAsync(CancellationToken cancellationToken = default)
        {
            var mapping      = DataEntityMapping.GetTableMapping(typeof(T));
            var queryCommand = _context.Database.QueryDelete(_context, mapping, _query);

            return(await _context.ExecuteNonQueryAsync(queryCommand.Command, _level, cancellationToken));
        }
예제 #3
0
        public override async Task <int> InsertAsync <K>(CancellationToken cancellationToken = default)
        {
            var insertMapping = DataEntityMapping.GetTableMapping(typeof(K));
            var queryCommand  = _context.Database.SelectInsert(_context, insertMapping, _mapping, _query, _order);

            return(await _context.ExecuteNonQueryAsync(queryCommand.Command, _level, cancellationToken));
        }
예제 #4
0
        public override int Insert <K>()
        {
            var insertMapping = DataEntityMapping.GetTableMapping(typeof(K));
            var queryCommand  = _context.Database.SelectInsert(_context, insertMapping, _mapping, _query, _order);

            return(_context.ExecuteNonQuery(queryCommand.Command, _level));
        }
예제 #5
0
        public override async Task <int> UpdateAsync(Expression <Func <T, T> > expression, CancellationToken cancellationToken = default)
        {
            var mapping      = DataEntityMapping.GetTableMapping(typeof(T));
            var updator      = LambdaExpressionExtend.CreateMassUpdateExpression(expression);
            var queryCommand = _context.Database.QueryUpdate(_context, mapping, updator, _query);

            return(await _context.ExecuteNonQueryAsync(queryCommand.Command, _level, cancellationToken));
        }
예제 #6
0
        public override int Update(Expression <Func <T, T> > expression)
        {
            var mapping      = DataEntityMapping.GetTableMapping(typeof(T));
            var updator      = LambdaExpressionExtend.CreateMassUpdateExpression(expression);
            var queryCommand = _context.Database.QueryUpdate(_context, mapping, updator, _query);

            return(_context.ExecuteNonQuery(queryCommand.Command, _level));
        }
예제 #7
0
        private int CheckDbSave(bool refresh, SafeLevel level)
        {
            var context = GetContext();
            var mapping = DataEntityMapping.GetTableMapping(GetType());
            var ret     = context.InsertOrUpdate(mapping, this, level, refresh);

            return(ret);
        }
예제 #8
0
        private int SimpleSave(bool refresh)
        {
            var context = GetContext();
            var mapping = DataEntityMapping.GetTableMapping(GetType());
            var ret     = _hasLoadData ? context.Update(mapping, this, refresh) : context.Insert(mapping, this, refresh);

            return(ret);
        }
예제 #9
0
        private async Task <int> CheckDbSaveAsync(bool refresh, SafeLevel level, CancellationToken cancellationToken = default)
        {
            var context = GetContext();
            var mapping = DataEntityMapping.GetTableMapping(GetType());
            var ret     = await context.InsertOrUpdateAsync(mapping, this, level, refresh, cancellationToken);

            return(ret);
        }
예제 #10
0
        private int CheckDbSave(bool refresh, SafeLevel level)
        {
            DataContext            context = GetContext();
            int                    ret;
            DataTableEntityMapping mapping = DataEntityMapping.GetTableMapping(this.GetType());

            ret = context.InsertOrUpdate(mapping, this, level, refresh);
            return(ret);
        }
예제 #11
0
        private int SimpleSave(bool refresh)
        {
            DataContext            context = GetContext();
            int                    ret;
            DataTableEntityMapping mapping = DataEntityMapping.GetTableMapping(this.GetType());

            if (_hasLoadData)
            {
                ret = context.Update(mapping, this, refresh);
            }
            else
            {
                ret = context.Insert(mapping, this, refresh);
            }
            return(ret);
        }
예제 #12
0
 /// <summary>
 /// Allow update primary key when change the primary key.
 /// </summary>
 /// <param name="allow"></param>
 public void AllowUpdatePrimaryKey(bool allow = true)
 {
     if (allow)
     {
         allowUpdatePrimaryKey = true;
         if (_hasLoadData && rawKeys == null)
         {
             DataTableEntityMapping mapping = DataEntityMapping.GetTableMapping(GetType());
             SetRawPrimaryKeys(mapping.GetPrimaryKeys(this));
         }
     }
     else
     {
         allowUpdatePrimaryKey = false;
     }
 }
예제 #13
0
        /// <summary>
        /// Delete data
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <int> EraseAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            DataContext context = GetContext();
            int         ret;

            if (_hasLoadData)
            {
                DataTableEntityMapping mapping = DataEntityMapping.GetTableMapping(this.GetType());
                ret = await context.DeleteAsync(mapping, this, cancellationToken);
            }
            else
            {
                ret = 0;
            }
            return(ret);
        }
예제 #14
0
        /// <summary>
        /// Delete data
        /// </summary>
        /// <returns></returns>
        public int Erase()
        {
            DataContext context = GetContext();
            int         ret;

            if (_hasLoadData)
            {
                DataTableEntityMapping mapping = DataEntityMapping.GetTableMapping(this.GetType());
                ret = context.Delete(mapping, this);
            }
            else
            {
                ret = 0;
            }
            return(ret);
        }
예제 #15
0
        private async Task <int> SimpleSaveAsync(bool refresh, CancellationToken cancellationToken = default(CancellationToken))
        {
            DataContext            context = GetContext();
            int                    ret;
            DataTableEntityMapping mapping = DataEntityMapping.GetTableMapping(this.GetType());

            if (_hasLoadData)
            {
                ret = await context.UpdateAsync(mapping, this, refresh, cancellationToken);
            }
            else
            {
                ret = await context.InsertAsync(mapping, this, refresh, cancellationToken);
            }
            return(ret);
        }