public ApiServiceDao(IDbConnection connection, IDbResult dbResult) { //_connection = new SqlConnection(GetConnectionString()); _connection = connection; _connection.ConnectionString = GetConnectionString(); _dbResult = dbResult; }
internal ExecutedEventArgs GetEventArgs(ExecuteType type, IDbResult result) { var e = this._EventArgs ?? (this._EventArgs = new ExecutedEventArgs(this)); e.ExecuteType = type; e.Result = result; return(e); }
public StudentDao(IApiServiceDao apiServiceDao, IDbResult dbResult) { this.apiServiceDao = apiServiceDao; this.dbResult = dbResult; }
/// <summary> /// 表示 <see cref="Aoite.Data.DbEngine.Executed"/> 事件的处理方法。 /// </summary> /// <param name="engine">数据源查询与交互引擎的实例。</param> /// <param name="type">执行的类型。</param> /// <param name="result">操作的返回值。</param> /// <param name="command">执行的命令。</param> protected virtual void OnExecuted(IDbEngine engine, ExecuteType type, ExecuteCommand command, IDbResult result) { if (this._Manager != null) { this._Manager.InternalOnExecuted(engine, type, command, result); } var handler = this.Executed; if (handler != null) { handler(engine, command.GetEventArgs(type, result)); } }
internal void InternalOnExecuted(IDbEngine engine, ExecuteType type, ExecuteCommand command, IDbResult result) { this.OnExecuted(engine, type, command, result); }
internal void Completed(ExecuteType type, IDbResult result) { this._EndTime = DateTime.Now; var command = result.Command; var engine = result.Engine; var owner = engine.Owner; this._EngineName = owner.Name ?? owner.ConnectionString; this._Type = type; this._CommandText = command.CommandText; var dict = new Dictionary <string, string>(command.Parameters.Count); foreach (DbParameter p in command.Parameters) { string name = owner.Injector.DescribeParameter(result.Engine, p); string value = (Convert.IsDBNull(p.Value) || p.Value == null) ? null : p.Value.ToString(); dict.Add(name, value); } this._Parameters = dict; this._ExceptionMessage = result.IsSucceed ? null : result.Exception.Message; if (result.IsSucceed) { switch (type) { case ExecuteType.Reader: this._Value = "{DataReader}"; break; case ExecuteType.DataSet: var dataSet = (result.Value as DataSet); this._Value = "找到 " + dataSet.Tables.Count + " 张表"; for (int i = 0; i < dataSet.Tables.Count; i++) { if (i == 0) { this._Value = "("; } else { this._Value += ","; } this._Value += dataSet.Tables[i].Rows.Count; } if (dataSet.Tables.Count > 0) { this._Value += ")"; } break; case ExecuteType.Table: var dataTable = (result.Value as DataTable); this._Value = "找到 " + dataTable.Rows.Count + " 条记录"; break; case ExecuteType.NoQuery: this._Value = result.Value + " 行受影响"; break; default: this._Value = result.Value == null ? null : (result.Value.ToString() + "\t\t" + result.Value.GetType().ToString()); break; } } }
public StudentController(IApiServiceDao dao, IDbResult dbResult) { this.dao = dao; this.dbResult = dbResult; }
/// <summary> /// 命令执行前发生。 /// </summary> /// <param name="type">执行的类型。</param> /// <param name="result">操作的返回值。</param> protected virtual void OnExecuted(ExecuteType type, IDbResult result) { this._owner.InternalOnExecuted(this._Engine, type, this._Command, result); }
/// <summary> /// 表示 <see cref="Aoite.Data.DbEngineManager.Executed"/> 事件的处理方法。 /// </summary> /// <param name="engine">数据源查询与交互引擎的实例。</param> /// <param name="type">执行的类型。</param> /// <param name="result">操作的返回值。</param> /// <param name="command">执行的命令。</param> protected virtual void OnExecuted(IDbEngine engine, ExecuteType type, ExecuteCommand command, IDbResult result) { var handler = this.Executed; if (handler != null) { handler(engine, command.GetEventArgs(type, result)); } }
public ValuesController(IApiServiceDao dao, IDbResult dbResult) { this.dao = dao; this.dbResult = dbResult; }