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()); } }
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()); } }
public DS_Message GetSingle(int ID) { using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection)) { return(ct.DS_Message.Single(a => a.ID == ID)); } }
public void Update(DS_Message Message) { using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection)) { ct.DS_Message.Attach(Message, true); ct.SubmitChanges(); } }
public void Add(DS_Message Message) { using (var ct = new DS_MessageDataContext(DbHelperSQL.Connection)) { ct.DS_Message.InsertOnSubmit(Message); ct.SubmitChanges(); } }
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(); } }
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(); } }
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(); } }
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()); } }
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()); } }