public virtual List <TResult> ToList <TResult>() { using (var conn = this.GetConnection()) { return(DMObjectContainer.GetProvider().ExecuteDataReader(conn, this.CmdText, this.Parameters).ToList <TResult>()); } }
public virtual DataTable ToDataTable() { using (var conn = this.GetConnection()) { return(DMObjectContainer.GetProvider().ExecuteDataTable(conn, this.CmdText, this.Parameters)); } }
private void BeginNewTransaction() { var conn = DMObjectContainer.GetProvider().GetConnection(this.ConnectionString); if (conn.State == ConnectionState.Closed) { conn.Open(); } this.trans = conn.BeginTransaction(); }
public virtual TResult ExecuteScalar <TResult>() { if (this.Trans == null) { using (var conn = this.GetConnection()) { return(DMObjectContainer.GetProvider().ExecuteScalar(conn, this.CmdText, this.Parameters).ToType <TResult>()); } } else { return(DMObjectContainer.GetProvider().ExecuteScalar(this.Trans, this.CmdText, this.Parameters).ToType <TResult>()); } }
public virtual int ExecuteNonQuery() { if (this.Trans == null) { using (var conn = this.GetConnection()) { return(DMObjectContainer.GetProvider().ExecuteNonQuery(conn, this.CmdText, this.Parameters)); } } else { return(DMObjectContainer.GetProvider().ExecuteNonQuery(this.Trans, this.CmdText, this.Parameters)); } }
public virtual ATSqlCommand AddParameter(string name, object value) { var param = DMObjectContainer.GetProvider().CreateParameter(name, value); if (this.CmdText.Contains(param.ParameterName)) { if (this.Parameters == null) { this.Parameters = new List <IDbDataParameter>(); } this.Parameters.Add(param); } return(this); }
private IDbConnection GetConnection() { return(DMObjectContainer.GetProvider().GetConnection(this.ConnectionString)); }