public override int Delete() { var mapping = DataEntityMapping.GetTableMapping(typeof(T)); var queryCommand = _context.Database.QueryDelete(_context, mapping, _query); return(_context.ExecuteNonQuery(queryCommand.Command, _level)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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); }
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); }
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); }
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); }
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); }
/// <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; } }
/// <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); }
/// <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); }
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); }