Пример #1
0
 public List <T> Query <T>(string sql, params object[] parameterValues)
 {
     using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection))
     {
         return(ct.ExecuteQuery <T>(sql, parameterValues).ToList());
     }
 }
Пример #2
0
 public static int GetMsgNum(int memberId, bool isView)
 {
     using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection))
     {
         return(ct.DS_Message.Where(a => a.MemberID.Equals(memberId) && a.IsView.Equals(isView)).Count());
     }
 }
Пример #3
0
 public DS_Message GetSingle(int ID)
 {
     using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection))
     {
         return(ct.DS_Message.Single(a => a.ID == ID));
     }
 }
Пример #4
0
 public void Update(DS_Message Message)
 {
     using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection))
     {
         ct.DS_Message.Attach(Message, true);
         ct.SubmitChanges();
     }
 }
Пример #5
0
 public void Add(DS_Message Message)
 {
     using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection))
     {
         ct.DS_Message.InsertOnSubmit(Message);
         ct.SubmitChanges();
     }
 }
Пример #6
0
 public void Delete(int ID)
 {
     using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection))
     {
         DS_Message st = ct.DS_Message.Single(a => a.ID == ID);
         ct.DS_Message.DeleteOnSubmit(st);
         ct.SubmitChanges();
     }
 }
Пример #7
0
 public void Delete(string Ids)
 {
     using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection))
     {
         string[] idarray = Ids.Split(',');
         var      list    = ct.DS_Message.Where(a => idarray.Contains(a.ID.ToString()));
         ct.DS_Message.DeleteAllOnSubmit(list);
         ct.SubmitChanges();
     }
 }
Пример #8
0
 public void ChgState(string Ids, bool isView)
 {
     using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection))
     {
         string[] idarray = Ids.Split(',');
         var      list    = ct.DS_Message.Where(a => idarray.Contains(a.ID.ToString()));
         foreach (var item in list)
         {
             item.IsView = isView;
         }
         ct.SubmitChanges();
     }
 }
Пример #9
0
 public List <DS_Message> Query(string condition, string orderby, params object[] param)
 {
     using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection))
     {
         IQueryable <DS_Message> MessageList = ct.DS_Message;
         if (!string.IsNullOrEmpty(condition))
         {
             MessageList = MessageList.Where(condition, param);
         }
         if (!string.IsNullOrEmpty(orderby))
         {
             MessageList = MessageList.OrderBy(orderby);
         }
         return(MessageList.ToList());
     }
 }
Пример #10
0
 public List <DS_Message> Query(string condition, string orderby, int startIndex, int pageSize, ref int pageCount, params object[] param)
 {
     using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection))
     {
         IQueryable <DS_Message> MessageList = ct.DS_Message;
         if (!string.IsNullOrEmpty(condition))
         {
             MessageList = MessageList.Where(condition, param);
         }
         if (!string.IsNullOrEmpty(orderby))
         {
             MessageList = MessageList.OrderBy(orderby);
         }
         pageCount = MessageList.Count();
         return(MessageList.Skip(startIndex).Take(pageSize).ToList());
     }
 }