Пример #1
0
 public async Task <IEnumerable <TEntity> > AllAsync(Transaction transaction = default, CancellationToken cancellationToken = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: DynamicQuery.All <TEntity>(_provider), transaction: transaction))
     {
         return(await CommandExecuter.ExecuteQueryAsync <TEntity>(_dbConnection, command, cancellationToken));
     }
 }
Пример #2
0
 public TEntity Find(object id, Transaction transaction = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: DynamicQuery.Find <TEntity>(_provider, _key), key: _key.Name, id: id, transaction: transaction))
     {
         return(CommandExecuter.ExecuteQuery <TEntity>(_dbConnection, command).FirstOrDefault());
     }
 }
Пример #3
0
 public IEnumerable <TEntity> All(Transaction transaction = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: DynamicQuery.All <TEntity>(_provider), transaction: transaction))
     {
         return(CommandExecuter.ExecuteQuery <TEntity>(_dbConnection, command));
     }
 }
Пример #4
0
 public async Task DeleteAsync(object id, Transaction transaction = default, CancellationToken cancellationToken = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: DynamicQuery.Delete <TEntity>(_provider, _key), _key.Name, id: id, transaction: transaction))
     {
         await CommandExecuter.ExecuteNonQueryAsync(_dbConnection, command, cancellationToken);
     }
 }
Пример #5
0
 public void Delete(object id, Transaction transaction = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: DynamicQuery.Delete <TEntity>(_provider, _key), key: _key.Name, id: id, transaction: transaction))
     {
         CommandExecuter.ExecuteNonQuery(_dbConnection, command);
     }
 }
Пример #6
0
 public async Task <TEntity> FindAsync(object id, Transaction transaction = default, CancellationToken cancellationToken = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: DynamicQuery.Find <TEntity>(_provider, _key), key: _key.Name, id: id, transaction: transaction))
     {
         return((await CommandExecuter.ExecuteQueryAsync <TEntity>(_dbConnection, command, cancellationToken)).FirstOrDefault());
     }
 }
Пример #7
0
 public IEnumerable <TEntity> Where(string whereCondition, object param = default, Transaction transaction = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: DynamicQuery.Where <TEntity>(_provider, whereCondition), param: param, transaction: transaction))
     {
         return(CommandExecuter.ExecuteQuery <TEntity>(_dbConnection, command));
     }
 }
Пример #8
0
 public void RawNonQuery(string query, object param = default, Transaction transaction = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: query, param: param, transaction: transaction))
     {
         CommandExecuter.ExecuteNonQuery(_dbConnection, command);
     }
 }
Пример #9
0
 public async Task <TResult> RawScalarQueryAsync <TResult>(string query, object param = default, Transaction transaction = default, CancellationToken cancellationToken = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: query, param: param, transaction: transaction))
     {
         return((TResult)(await CommandExecuter.ExecuteScalarQueryAsync(_dbConnection, command, cancellationToken)));
     }
 }
Пример #10
0
 public async Task <IEnumerable <TEntity> > RawQueryAsync <TEntity>(string query, object param = default, Transaction transaction = default, CancellationToken cancellationToken = default) where TEntity : class
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: query, param: param, transaction: transaction))
     {
         return(await CommandExecuter.ExecuteQueryAsync <TEntity>(_dbConnection, command, cancellationToken));
     }
 }
Пример #11
0
 public TResult RawScalarQuery <TResult>(string query, object param = default, Transaction transaction = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: query, param: param, transaction: transaction))
     {
         return((TResult)CommandExecuter.ExecuteScalarQuery(_dbConnection, command));
     }
 }
Пример #12
0
 public IEnumerable <TEntity> RawQuery <TEntity>(string query, object param = default, Transaction transaction = default) where TEntity : class
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: query, param: param, transaction: transaction))
     {
         return(CommandExecuter.ExecuteQuery <TEntity>(_dbConnection, command));
     }
 }
Пример #13
0
 public async Task RawNonQueryAsync(string query, object param = default, Transaction transaction = default, CancellationToken cancellationToken = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: query, param: param, transaction: transaction))
     {
         await CommandExecuter.ExecuteNonQueryAsync(_dbConnection, command, cancellationToken);
     }
 }
Пример #14
0
 public async Task <IEnumerable <TEntity> > WhereAsync(string whereCondition, object param = default, Transaction transaction = default, CancellationToken cancellationToken = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, commandText: DynamicQuery.Where <TEntity>(_provider, whereCondition), param: param, transaction: transaction))
     {
         return(await CommandExecuter.ExecuteQueryAsync <TEntity>(_dbConnection, command, cancellationToken));
     }
 }
Пример #15
0
 public void Update(TEntity item, Transaction transaction = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection))
     {
         var properties = CommandExecuter.GetProperticeWithAddParameters <TEntity>(_provider, _key, _keyIsAutoId, item, command);
         command.CommandText = DynamicQuery.Update(_provider, _key, properties, item);
         CommandExecuter.ExecuteNonQuery(_dbConnection, command);
     }
 }
Пример #16
0
 public async Task UpdateAsync(TEntity item, Transaction transaction = default, CancellationToken cancellationToken = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, transaction: transaction))
     {
         var properties = CommandExecuter.GetProperticeWithAddParameters <TEntity>(_provider, _key, _keyIsAutoId, item, command);
         command.CommandText = DynamicQuery.Update(_provider, _key, properties, item);
         await CommandExecuter.ExecuteNonQueryAsync(_dbConnection, command, cancellationToken);
     }
 }
Пример #17
0
 public void Insert(TEntity item, Transaction transaction = default)
 {
     using (var command = CommandDefinition.GetCommand(provider: _provider, connection: _dbConnection, transaction: transaction))
     {
         var properties = CommandExecuter.GetProperticeWithAddParameters <TEntity>(_provider, _key, _keyIsAutoId, item, command);
         command.CommandText = DynamicQuery.Insert(_provider, _key, properties, item);
         var key = CommandExecuter.ExecuteScalarQuery(_dbConnection, command);
         if (_keyIsAutoId)
         {
             var value = Convert.ChangeType(key, _key.PropertyType);
             _key.SetValue(item, value);
         }
     }
 }