public List <object> ExecuteGoQuery(string query, bool noTransaction = true, DBExecuteType type = DBExecuteType.Scalar) { var result = new List <object>(); foreach (var go in SplitGoQuery(query)) { result.Add(ExecuteQuery(go, noTransaction, type)); } return(result); }
internal void OnExecute(DBExecuteType type, string text, TimeSpan ms, object rez) { if (rez is Exception ex) { Helper.Logs.Add(new StateInfo("Transaction", ex.Message, text, StatusType.Warning)); } Execute?.Invoke(new DBExecuteEventArg { Time = ms, Query = text, Type = type, Rezult = rez }); }
public object ExecuteQuery(string query, bool noTransaction = false, DBExecuteType type = DBExecuteType.Scalar) { if (string.IsNullOrEmpty(query)) { return(null); } using (var transaction = new DBTransaction(this, null, noTransaction)) { var result = transaction.ExecuteQuery(transaction.AddCommand(query), type); transaction.Commit(); return(result); } }
public override async Task <object> ExecuteQueryAsync(IDbCommand command, DBExecuteType type, CommandBehavior behavior) { var npgsqlCommand = (NpgsqlCommand)command; switch (type) { case DBExecuteType.Scalar: return(await npgsqlCommand.ExecuteScalarAsync()); case DBExecuteType.Reader: return(await npgsqlCommand.ExecuteReaderAsync(behavior)); case DBExecuteType.NoReader: return(await npgsqlCommand.ExecuteNonQueryAsync()); } return(null); }
public object ExecuteQuery(IDbCommand command, DBExecuteType type = DBExecuteType.Scalar, CommandBehavior behavior = CommandBehavior.Default) { object buf = null; var watch = new Stopwatch(); try { //Debug.WriteLine(command.Connection.ConnectionString); //Debug.WriteLine(command.CommandText); watch.Start(); switch (type) { case DBExecuteType.Scalar: buf = command.ExecuteScalar(); break; case DBExecuteType.Reader: buf = command.ExecuteReader(behavior); break; case DBExecuteType.NoReader: buf = command.ExecuteNonQuery(); break; } watch.Stop(); } catch (Exception ex) { Rollback(); buf = ex; } finally { OnExecute(type, command.CommandText, watch.Elapsed, buf); if (buf is Exception) { throw (Exception)buf; } } return(buf); }
public object ExecuteQuery(string commandText, DBExecuteType type = DBExecuteType.Scalar) { return(ExecuteQuery(AddCommand(commandText), type)); }
public object ExecuteQuery(DBExecuteType type = DBExecuteType.Scalar) { return(ExecuteQuery(Command, type)); }
public override Task <object> ExecuteQueryAsync(IDbCommand command, DBExecuteType type, CommandBehavior behavior) { throw new NotImplementedException(); }