/// <summary> /// 根据接收人查询邮件列表 /// </summary> public SiteMessageInnerMailListNew_Collection QueryUnReadInnerMailList_ByReceiverId(string userId, int pageIndex, int pageSize, int handleType) { Session.Clear(); SiteMessageInnerMailListNew_Collection collection = new SiteMessageInnerMailListNew_Collection(); collection.TotalCount = 0; var query = from m in Session.Query <SiteMessageInnerMailListNew>() where (m.ReceiverId == userId || m.ReceiverId == "U:" + userId) && m.HandleType == (InnerMailHandleType)handleType select new SiteMessageInnerMailListNewInfo { HandleType = m.HandleType, MailId = m.MailId, MsgContent = m.MsgContent, ReadTime = m.ReadTime, ReceiverId = m.ReceiverId, SenderId = m.SenderId, SendTime = m.SendTime, Title = m.Title, }; if (query != null) { collection.TotalCount = query.Count(); collection.MailList = query.Skip(pageIndex * pageSize).Take(pageSize).ToList(); } return(collection); }
//public InnerMailInfo_QueryCollection QueryUnReadInnerMailListByReceiver(string userId, int pageIndex, int pageSize, InnerMailHandleType handleType) //{ // using (var manager = new InnerMailManager()) // { // var result = new InnerMailInfo_QueryCollection(); // int totalCount; // var list = manager.QueryUnReadInnerMailList_ByReceiverId(userId, pageIndex, pageSize, Convert.ToInt32(handleType), out totalCount); // result.LoadList(list); // if (result != null && result.InnerMailList != null) // { // result.TotalCount = totalCount; // //var tempResult = result.InnerMailList.Where(s => s.HandleType == handleType); // //if (tempResult != null && tempResult.Count() > 0) // //{ // // result.TotalCount = tempResult.Count(); // // result.InnerMailList = tempResult.Skip(pageIndex * pageSize).Take(pageSize).ToList(); // //} // } // return result; // } //} public SiteMessageInnerMailListNew_Collection QueryUnReadInnerMailListByReceiver(string userId, int pageIndex, int pageSize, InnerMailHandleType handleType) { using (var manager = new InnerMailManager()) { var result = new SiteMessageInnerMailListNew_Collection(); return(manager.QueryUnReadInnerMailList_ByReceiverId(userId, pageIndex, pageSize, Convert.ToInt32(handleType))); } }
public SiteMessageInnerMailListNew_Collection QueryInnerMailListByReceiver(string userId, int pageIndex, int pageSize) { SiteMessageInnerMailListNew_Collection collection = new SiteMessageInnerMailListNew_Collection(); collection.TotalCount = 0; //var query = from m in Session.Query<SiteMessageInnerMailListNew>() // where m.ReceiverId == "U:"+userId // select new SiteMessageInnerMailListNewInfo // { // HandleType = m.HandleType, // MailId = m.MailId, // MsgContent = m.MsgContent, // ReadTime = m.ReadTime, // ReceiverId = m.ReceiverId, // SenderId = m.SenderId, // SendTime = m.SendTime, // Title = m.Title, // }; var query = from m in DB.CreateQuery <E_SiteMessage_InnerMail_List_new>() where (m.ReceiverId == userId || m.ReceiverId == "U:" + userId) && m.HandleType != (int)InnerMailHandleType.Deleted select m; if (query != null) { collection.TotalCount = query.Count(); collection.MailList = query.Skip(pageIndex * pageSize).Take(pageSize).ToList().Select(m => new SiteMessageInnerMailListNewInfo { HandleType = (InnerMailHandleType)m.HandleType, MailId = m.MailId, MsgContent = m.MsgContent, ReadTime = m.ReadTime, ReceiverId = m.ReceiverId, SenderId = m.SenderId, SendTime = m.SendTime, Title = m.Title, }).ToList(); } return(collection); }