Exemple #1
0
 protected virtual void InitPageCount()
 {
     using (DbCommandWrapped wrapped = this.DbHelper.CreateDbCommandWrapped(this.CreateSqlCountCommand(), this.Condition.Parameters))
     {
         this.RecordCount = wrapped.ExecuteScalar().As <int>();
     }
 }
Exemple #2
0
 protected List <T> ExecuteDbObjectList <T>(DbCommandWrapped command)
 {
     using (command)
     {
         return(command.ExecuteDbObjectList <T>());
     }
 }
Exemple #3
0
        protected DataSet ExecuteDataSet(DbCommandWrapped command)
        {
            DataSet dataset = new DataSet();

            this.FillDataSet(dataset, command);
            return(dataset);
        }
Exemple #4
0
        public virtual List <T> ReadAsDbObjectList <T>()
        {
            List <T> list;

            try
            {
                this.BeginExecute();
                this.InitPageCount();
                int startIndex = (this.PageNumber - 1) * this.PageSize;
                if (this.RecordCount > 0)
                {
                    StringBuilder builder = new StringBuilder(this.Select.Length + 40);
                    builder.Append(this.Select);
                    builder.Append(this.Condition.ToString());
                    using (DbCommandWrapped wrapped = this.DbHelper.CreateDbCommandWrapped(builder.ToString(), this.Condition.Parameters))
                    {
                        return(wrapped.ExecuteDbObjectList <T>(startIndex, this.PageSize));
                    }
                }
                list = new List <T>();
            }
            finally
            {
                this.EndExecute();
            }
            return(list);
        }
Exemple #5
0
 protected long ExecuteIdentity(DbCommandWrapped command)
 {
     using (command)
     {
         return(this.ExecuteIdentity(command.Command, command.KeepConnection));
     }
 }
Exemple #6
0
        public override DataTable ReadAsDataTable()
        {
            DataTable table;

            try
            {
                this.BeginExecute();
                this.InitPageCount();
                if (base.RecordCount > 0)
                {
                    string queryCommand = this.GetQueryCommand();
                    using (DbCommandWrapped wrapped = base.DbHelper.CreateDbCommandWrapped(queryCommand.ToString(), base.Condition.Parameters))
                    {
                        DataSet ds = new DataSet();
                        using (DbDataAdapter adapter = base.DbHelper.CreateDbDataAdapter(wrapped.Command))
                        {
                            wrapped.FillDataSet(adapter, ds);
                            return((ds.Tables.Count > 0) ? ds.Tables[0] : null);
                        }
                    }
                }
                table = null;
            }
            finally
            {
                this.EndExecute();
            }
            return(table);
        }
Exemple #7
0
 protected object ExecuteScalar(DbCommandWrapped command)
 {
     using (command)
     {
         DateTime now  = DateTime.Now;
         object   obj2 = command.ExecuteScalar();
         this.ProcessSlowCommandLog(command.Command, now, DateTime.Now);
         return(obj2);
     }
 }
Exemple #8
0
 protected virtual DbDataReader ExecuteReader(DbCommandWrapped command)
 {
     using (command)
     {
         DateTime     now    = DateTime.Now;
         DbDataReader reader = command.ExecuteReader();
         this.ProcessSlowCommandLog(command.Command, now, DateTime.Now);
         return(reader);
     }
 }
Exemple #9
0
 protected int ExecuteNonQuery(DbCommandWrapped command)
 {
     using (command)
     {
         DateTime now = DateTime.Now;
         int      num = command.ExecuteNonQuery();
         this.ProcessSlowCommandLog(command.Command, now, DateTime.Now);
         return(num);
     }
 }
Exemple #10
0
 protected T ExecuteDbObject <T>(DbCommandWrapped command)
 {
     using (DbDataReader reader = this.ExecuteReader(command))
     {
         if (reader.Read())
         {
             return(reader.ToObject <T>());
         }
         return(default(T));
     }
 }
Exemple #11
0
 protected void FillDataSet(DataSet dataset, DbCommandWrapped command)
 {
     using (command)
     {
         DateTime now = DateTime.Now;
         using (DbDataAdapter adapter = this.CreateDbDataAdapter(command.Command))
         {
             command.FillDataSet(adapter, dataset);
         }
         this.ProcessSlowCommandLog(command.Command, now, DateTime.Now);
     }
 }
Exemple #12
0
        public override List <T> ReadAsDbObjectList <T>()
        {
            List <T> list;

            try
            {
                this.BeginExecute();
                this.InitPageCount();
                if (base.RecordCount > 0)
                {
                    string queryCommand = this.GetQueryCommand();
                    using (DbCommandWrapped wrapped = base.DbHelper.CreateDbCommandWrapped(queryCommand.ToString(), base.Condition.Parameters))
                    {
                        return(wrapped.ExecuteDbObjectList <T>());
                    }
                }
                list = new List <T>();
            }
            finally
            {
                this.EndExecute();
            }
            return(list);
        }
Exemple #13
0
 private DbCommandWrapped CreateDbCommandWrapped(DbCommand command)
 {
     return(DbCommandWrapped.Create(command, this.KeepConnection));
 }