I'm struggling to write a Query to fetch DirectMessages from a users inbox but I can't get it to work.
I get all kinds of strange errors when fiddleing around. Ideas and input is much appreciated.
This is what I currently have:
var mq = new MessageQuery();
var r = newMessageRecipientCollectionCriterion();
r.Containing = new MessageRecipientCriterion();
r.Containing.Recipient = new UserCriterion();
r.Containing.Recipient.ID = new IntegerCriterion();
r.Containing.Recipient.ID.Includes = new IntegerInCriterion();
r.Containing.Recipient.ID.Includes.Values.Add(_user.ID);
var f = new FolderCriterion();
f.Container = newDirectMessageContainerCriterion();
f.Container.User = new UserCriterion();
f.Container.User.ID = new IntegerCriterion {Value = _user.ID};
f.Container.Folders = new FolderBaseCollectionCriterion();
f.Container.Folders.Containing = new SystemFolderCriterion { FolderType = new SystemCriterion {Value = SystemFolderType.Inbox} };
f.Container.Folders.Containing.ID = new IntegerCriterion {Value = GetInbox().ID};
r.Containing.Folder = f;
mq.Recipients = r;
mq.SendDate = new DateTimeCriterion();
mq.OrderBy.Add(new CriterionSortOrder(mq.SendDate, SortingDirection.Descending));
QueryHandler.Instance.RemoveQueryResultCache(mq);
var messages = DirectMessageHandler.Instance.GetQueryResult(mq);
I'm struggling to write a Query to fetch DirectMessages from a users inbox but I can't get it to work.
I get all kinds of strange errors when fiddleing around. Ideas and input is much appreciated.
This is what I currently have:
var mq = new MessageQuery();
var r = newMessageRecipientCollectionCriterion();
r.Containing = new MessageRecipientCriterion();
r.Containing.Recipient = new UserCriterion();
r.Containing.Recipient.ID = new IntegerCriterion();
r.Containing.Recipient.ID.Includes = new IntegerInCriterion();
r.Containing.Recipient.ID.Includes.Values.Add(_user.ID);
var f = new FolderCriterion();
f.Container = newDirectMessageContainerCriterion();
f.Container.User = new UserCriterion();
f.Container.User.ID = new IntegerCriterion {Value = _user.ID};
f.Container.Folders = new FolderBaseCollectionCriterion();
f.Container.Folders.Containing = new SystemFolderCriterion { FolderType = new SystemCriterion {Value = SystemFolderType.Inbox} };
f.Container.Folders.Containing.ID = new IntegerCriterion {Value = GetInbox().ID};
r.Containing.Folder = f;
mq.Recipients = r;
mq.SendDate = new DateTimeCriterion();
mq.OrderBy.Add(new CriterionSortOrder(mq.SendDate, SortingDirection.Descending));
QueryHandler.Instance.RemoveQueryResultCache(mq);
var messages = DirectMessageHandler.Instance.GetQueryResult(mq);