Example #1
0
        /// <summary>
        /// 根据物理主码查询
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>结果</returns>
        public News SELECT_BY_ID(long id)
        {
            try
            {
                News   rd   = new News();
                U_news temp = (from row in db.U_news where row.id == id select row).First();

                rd.Id       = temp.id;
                rd.Mid      = temp.mid;
                rd.Title    = temp.title;
                rd.Context  = temp.context;
                rd.Datetime = temp.datetime;
                rd.Cn       = temp.cn;
                rd.Isused   = temp.isused;

                return(rd);
            }
            catch
            {
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// 插入函数
        /// </summary>
        /// <param name="info">Model</param>
        /// <returns>影响数据物理ID</returns>
        public long INSERT(News info)
        {
            try
            {
                U_news temp = new U_news();
                //temp.id = info.Id;
                temp.mid      = info.Mid;
                temp.title    = info.Title;
                temp.context  = info.Context;
                temp.datetime = info.Datetime;
                temp.cn       = info.Cn;
                temp.isused   = info.Isused;

                Table <U_news> table = db.GetTable <U_news>();
                table.InsertOnSubmit(temp);
                db.SubmitChanges();
                return(temp.id);
            }
            catch
            {
                return(-2);
            }
        }
Example #3
0
        /// <summary>
        /// 更新函数
        /// </summary>
        /// <param name="info">Model</param>
        /// <returns>影响数据物理ID,已存在逻辑主码返回-1</returns>
        public long UPDATE(News info)
        {
            try
            {
                U_news         temp  = new U_news();
                Table <U_news> table = db.GetTable <U_news>();
                temp = (from row in db.U_news where row.id == info.Id select row).First();

                //temp.id = info.Id;
                temp.mid      = info.Mid;
                temp.title    = info.Title;
                temp.context  = info.Context;
                temp.datetime = info.Datetime;
                temp.cn       = info.Cn;
                temp.isused   = info.Isused;

                db.SubmitChanges();
                return(temp.id);
            }
            catch
            {
                return(-2);
            }
        }