public override object Execute(DataTransaction dt, IDataCommand command)//funcName:tableName { if (destination == null) { return(null); } var v = (BaseDataCommand)command; var cmd = v.Sql.Split(':'); var func = destination._GetProperty("Repository")._InvokeMethod("CreateFunction", cmd[0]); var obj = func; if (cmd.Length > 1) { var tbl = GetTable.Invoke(func, new[] { cmd[1] }) as ICollection; tbl._InvokeMethod("Clear"); tbl._InvokeMethod("Append"); var row = tbl.GetEnumerator(); row.MoveNext(); obj = row.Current; } foreach (var x in v.Parameters) { SetValue.Invoke(obj, new[] { x.Key, x.Value }); } func._InvokeMethod("Invoke", destination); return(null); }
public DataTransaction BeginTransaction() { return(CurrentTransaction = new DataTransaction() { Transaction = new DataConnection(connection.BeginTransaction()) }); }
public static void UseTransaction(this IDataProvider dp, Action <DataTransaction> action, DataTransaction dt = null) { DataTransaction _dt = null; try { _dt = dt ?? dp.BeginTransaction(); action(_dt); if (dt == null) { if (AppContext.Log.UseTrace) { AppContext.Log.Trace("Commit"); } dp.CommitTransaction(_dt); } } catch (Exception ex) { if (dt == null) { if (AppContext.Log.UseTrace) { AppContext.Log.Trace("Rollback: " + ex.Message); } if (_dt != null) { dp.RollbackTransaction(_dt); } } throw; } }
public object Execute(DataTransaction dt, IDataCommand command) { var dc = (dt ?? CurrentTransaction)?.Transaction as DataConnection; var cmd = (DataCommand)command; return(dc == null?DoAction(cmd.ExecuteScalar) : cmd.ExecuteScalar(dc)); }
public override object Execute(DataTransaction dt, IDataCommand command) { var cmd = ""; var v = (BaseDataCommand)command; try { cmd = v.Sql.FormatStrEx(v.Parameters); if (AppContext.Log.UseTrace) { AppContext.Log.Trace(cmd); } return(proxy.Exec(new ExecRequest() { Body = new ExecRequestBody() { cmd = cmd } }).Body.@return); } catch (Exception ex) { var info = GetExMessage(ex, cmd); if (info.IsEmpty()) { throw; } else { throw new Exception(info); } } }
public static void Execute <T>(this IDataProvider dp, DataTransaction dt, string command, List <T> prms, Action <IDataCommand, T> prepare, Action <object, T> onResult) { var cmd = dp.CreateCommand(command); foreach (var p in prms) { cmd.ClearParams(); prepare?.Invoke(cmd, p); var v = dp.Execute(dt, cmd); onResult?.Invoke(v, p); } }
public virtual void RollbackTransaction(DataTransaction dt) { }
public virtual void CommitTransaction(DataTransaction dt) { }
public static object Execute(this IDataProvider dp, DataTransaction dt, string command, params object[] prms) { return(dp.Execute(dt, dp.CreateCommand(command, prms))); }
public abstract object Execute(DataTransaction dt, IDataCommand command);
public void RollbackTransaction(DataTransaction dt) { (dt?.Transaction as DataConnection)?.Transaction?.Rollback(); CurrentTransaction = null; }
public void CommitTransaction(DataTransaction dt) { (dt?.Transaction as DataConnection)?.Transaction?.Commit(); CurrentTransaction = null; }