示例#1
0
 protected virtual void InitPageCount()
 {
     using (DbCommandWrapped wrapped = this.DbHelper.CreateDbCommandWrapped(this.CreateSqlCountCommand(), this.Condition.Parameters))
     {
         this.RecordCount = wrapped.ExecuteScalar().As <int>();
     }
 }
示例#2
0
文件: DbHelper.cs 项目: liyu7342/QL
 protected List <T> ExecuteDbObjectList <T>(DbCommandWrapped command)
 {
     using (command)
     {
         return(command.ExecuteDbObjectList <T>());
     }
 }
示例#3
0
文件: DbHelper.cs 项目: liyu7342/QL
        protected DataSet ExecuteDataSet(DbCommandWrapped command)
        {
            DataSet dataset = new DataSet();

            this.FillDataSet(dataset, command);
            return(dataset);
        }
示例#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);
        }
示例#5
0
 protected long ExecuteIdentity(DbCommandWrapped command)
 {
     using (command)
     {
         return(this.ExecuteIdentity(command.Command, command.KeepConnection));
     }
 }
示例#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);
        }
示例#7
0
文件: DbHelper.cs 项目: liyu7342/QL
 protected object ExecuteScalar(DbCommandWrapped command)
 {
     using (command)
     {
         DateTime now  = DateTime.Now;
         object   obj2 = command.ExecuteScalar();
         this.ProcessSlowCommandLog(command.Command, now, DateTime.Now);
         return(obj2);
     }
 }
示例#8
0
文件: DbHelper.cs 项目: liyu7342/QL
 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);
     }
 }
示例#9
0
文件: DbHelper.cs 项目: liyu7342/QL
 protected int ExecuteNonQuery(DbCommandWrapped command)
 {
     using (command)
     {
         DateTime now = DateTime.Now;
         int      num = command.ExecuteNonQuery();
         this.ProcessSlowCommandLog(command.Command, now, DateTime.Now);
         return(num);
     }
 }
示例#10
0
文件: DbHelper.cs 项目: liyu7342/QL
 protected T ExecuteDbObject <T>(DbCommandWrapped command)
 {
     using (DbDataReader reader = this.ExecuteReader(command))
     {
         if (reader.Read())
         {
             return(reader.ToObject <T>());
         }
         return(default(T));
     }
 }
示例#11
0
文件: DbHelper.cs 项目: liyu7342/QL
 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);
     }
 }
示例#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);
        }
示例#13
0
文件: DbHelper.cs 项目: liyu7342/QL
 private DbCommandWrapped CreateDbCommandWrapped(DbCommand command)
 {
     return(DbCommandWrapped.Create(command, this.KeepConnection));
 }