Exemplo n.º 1
0
 public virtual List <TResult> ToList <TResult>()
 {
     using (var conn = this.GetConnection())
     {
         return(DMObjectContainer.GetProvider().ExecuteDataReader(conn, this.CmdText, this.Parameters).ToList <TResult>());
     }
 }
Exemplo n.º 2
0
 public virtual DataTable ToDataTable()
 {
     using (var conn = this.GetConnection())
     {
         return(DMObjectContainer.GetProvider().ExecuteDataTable(conn, this.CmdText, this.Parameters));
     }
 }
Exemplo n.º 3
0
        private void BeginNewTransaction()
        {
            var conn = DMObjectContainer.GetProvider().GetConnection(this.ConnectionString);

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            this.trans = conn.BeginTransaction();
        }
Exemplo n.º 4
0
 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>());
     }
 }
Exemplo n.º 5
0
 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));
     }
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 private IDbConnection GetConnection()
 {
     return(DMObjectContainer.GetProvider().GetConnection(this.ConnectionString));
 }