public List <PrivateChatMessage> GetScrollingChatData(string fromid, string toid, int start = 10, int length = 1) { takeCounter = (length * start); // 20 skipCounter = ((length - 1) * start); // 10 List <PrivateChatMessage> msg = new List <PrivateChatMessage>(); var uow = new XpoDAO().ProvideUnitOfWork(); var ChatPrivateMessageMasters = new XPCollection <ChatPrivateMessageMaster>(uow); var ChatPrivateMessageDetails = new XPCollection <ChatPrivateMessageDetail>(uow); var v = (from a in ChatPrivateMessageMasters join b in ChatPrivateMessageDetails on a.EmailID equals b.MasterEmailID into cc from c in cc where (c.MasterEmailID.Equals(fromid) && c.ChatToEmailID.Equals(toid)) || (c.MasterEmailID.Equals(toid) && c.ChatToEmailID.Equals(fromid)) //orderby c.ID descending select new { UserName = a.UserName, Message = c.Message, //ID = c.ID }).Take(takeCounter).Skip(skipCounter).ToList(); foreach (var a in v) { var res = new PrivateChatMessage() { userName = a.UserName, message = a.Message }; msg.Add(res); } return(msg); }
public List <PrivateChatMessage> GetPrivateMessage(string fromid, string toid, int take) { List <PrivateChatMessage> msg = new List <PrivateChatMessage>(); var uow = new XpoDAO().ProvideUnitOfWork(); var ChatUserDetails = new XPCollection <ChatPrivateMessageMaster>(uow); var ChatPrivateMessageDetails = new XPCollection <ChatPrivateMessageDetail>(uow); var v = (from a in ChatUserDetails join b in ChatPrivateMessageDetails on a.EmailID equals b.MasterEmailID into cc from c in cc where (c.MasterEmailID.Equals(fromid) && c.ChatToEmailID.Equals(toid)) || (c.MasterEmailID.Equals(toid) && c.ChatToEmailID.Equals(fromid)) //orderby c.ID descending select new { UserName = a.UserName, Message = c.Message, //ID = c.ID }).Take(take).ToList(); //v = v.OrderBy(s => s.ID).ToList(); foreach (var a in v) { var res = new PrivateChatMessage() { userName = a.UserName, message = a.Message }; msg.Add(res); } return(msg); }