public virtual void Delete(Entity entity)
 {
     if (entity != null && this.DataObject != null)
     {
         DataTransaction tran = new DataTransaction(this.DataObject.ConnectionString);
         try
         {
             this.DataObject.Delete(entity, tran);
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         tran.Commit();
     }
 }
Пример #2
0
        private int ExecuteNonQuery(string connectionString, DataTransaction tran)
        {
            if (tran == null)
            {
                this.Command.Connection.ConnectionString = connectionString;
                this.Command.Connection.Open();
            }
            else
            {
                this.Command.Connection  = tran.Transaction.Connection;
                this.Command.Transaction = tran.Transaction;
            }

            this.Command.CommandText = this.Query;
            this.Command.CommandType = this.Type;
            int ret = this.Command.ExecuteNonQuery();

            if (tran == null)
            {
                this.Command.Connection.Close();
            }
            return(ret);
        }
Пример #3
0
        private DataTable GetDataTable(string connectionString, DataTransaction tran)
        {
            if (tran == null)
            {
                this.Command.Connection.ConnectionString = connectionString;
            }
            else
            {
                this.Command.Connection  = tran.Transaction.Connection;
                this.Command.Transaction = tran.Transaction;
            }

            this.Command.CommandText = this.Query;
            this.Command.CommandType = this.Type;

            SqlDataAdapter adp = new SqlDataAdapter();

            adp.SelectCommand = this.Command;
            DataTable dt = new DataTable();

            adp.Fill(dt);

            return(dt);
        }
        private object ExecuteScalar(string connectionString, DataTransaction tran)
        {
            if (tran == null)
            {
                this.Command.Connection.ConnectionString = connectionString;
                this.Command.Connection.Open();
            }
            else
            {
                this.Command.Connection  = tran.Transaction.Connection;
                this.Command.Transaction = tran.Transaction;
            }

            this.Command.CommandText = this.Name;
            this.Command.CommandType = CommandType.StoredProcedure;
            object ret = this.Command.ExecuteScalar();

            if (tran == null)
            {
                this.Command.Connection.Close();
            }

            return(ret);
        }
Пример #5
0
        private DataSet GetDataSet(string connectionString, DataTransaction tran)
        {
            if (tran == null)
            {
                this.Command.Connection.ConnectionString = connectionString;
            }
            else
            {
                this.Command.Connection  = tran.Transaction.Connection;
                this.Command.Transaction = tran.Transaction;
            }

            this.Command.CommandText = this.Name;
            this.Command.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter adp = new SqlDataAdapter();

            adp.SelectCommand = this.Command;
            DataSet ds = new DataSet();

            adp.Fill(ds);

            return(ds);
        }
Пример #6
0
 public object ExecuteScalar(DataTransaction tran)
 {
     return(this.ExecuteScalar(null, tran));
 }
Пример #7
0
 public DataTable GetDataTable(DataTransaction tran)
 {
     return(this.GetDataTable(null, tran));
 }
Пример #8
0
 public int ExecuteNonQuery(DataTransaction tran)
 {
     return(this.ExecuteNonQuery(null, tran));
 }
 public virtual int Delete(Entity entity, DataTransaction tran)
 {
     return(0);
 }
 public virtual int Insert(Entity entity, DataTransaction tran)
 {
     return(0);
 }
Пример #11
0
 public DataSet GetDataSet(DataTransaction tran)
 {
     return(this.GetDataSet(null, tran));
 }