Beispiel #1
0
        private void SetProperty(DBlogRecord record, SqlDataReader reader)
        {
            var r  = record;
            var dr = reader;

            r.BlogCD     = (Guid)dr["BlogCD"];
            r.Title      = dr["Title"].ToString();
            r.CreateTime = (DateTimeOffset)dr["CreateTime"];
            r.UserCD     = (Guid)dr["UserCD"];
            r.BdoyText   = dr["BodyText"].ToString();
        }
Beispiel #2
0
        public List <DBlogRecord> DBlog_List_Get()
        {
            var l = new List <DBlogRecord>();

            using (var cn = new SqlConnection(this.ConnectionString))
            {
                var cm = new SqlCommand("select * from DBlog");
                cm.Connection = cn;

                cn.Open();
                var dr = cm.ExecuteReader();
                while (dr.Read())
                {
                    var r = new DBlogRecord();
                    this.SetProperty(r, dr);
                    l.Add(r);
                }
            }
            return(l);
        }
Beispiel #3
0
        public List <DBlogRecord> DBlog_List_Get_By_Title(String title)
        {
            var l = new List <DBlogRecord>();

            using (var cn = new SqlConnection(this.ConnectionString))
            {
                var sql = String.Format("select * from DBlog where Title = '{0}'", title);
                var cm  = new SqlCommand(sql);
                cm.Connection = cn;

                cn.Open();
                var dr = cm.ExecuteReader();
                while (dr.Read())
                {
                    var r = new DBlogRecord();
                    this.SetProperty(r, dr);
                    l.Add(r);
                }
            }
            return(l);
        }
Beispiel #4
0
        public List <DBlogRecord> DBlog_List_Get_By_Date(DateTime date)
        {
            var l = new List <DBlogRecord>();

            using (var cn = new SqlConnection(this.ConnectionString))
            {
                var sql = String.Format("select * from DBlog where '{0}' <= CreateTime and CreateTime < '{1}'"
                                        , date.ToString("yyyy/MM/dd 00:00"), date.AddDays(1).ToString("yyyy/MM/dd 00:00"));
                var cm = new SqlCommand(sql);
                cm.Connection = cn;

                cn.Open();
                var dr = cm.ExecuteReader();
                while (dr.Read())
                {
                    var r = new DBlogRecord();
                    this.SetProperty(r, dr);
                    l.Add(r);
                }
            }
            return(l);
        }