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

            this.FillDataSet(dataset, command);
            return(dataset);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 protected long ExecuteIdentity(DbCommandWrapped command)
 {
     using (command)
     {
         return(this.ExecuteIdentity(command.Command, command.KeepConnection));
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 10
0
 protected T ExecuteDbObject <T>(DbCommandWrapped command)
 {
     using (DbDataReader reader = this.ExecuteReader(command))
     {
         if (reader.Read())
         {
             return(reader.ToObject <T>());
         }
         return(default(T));
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 13
0
 private DbCommandWrapped CreateDbCommandWrapped(DbCommand command)
 {
     return(DbCommandWrapped.Create(command, this.KeepConnection));
 }