You could either do something like this:
ContactRelationCollection contacts = sc.ContactHandler.GetContacts(myPage.Contact, ContactType.Contact, Perspective.ToMe, page, pageSize, sortOrder);
List<ContactRelation> nonRemovedContacts = contacts.Where(contact => !contact.ContactUser.Removed).ToList();
Or use the query system to get all none removed contacts.
I can't really use that solution if I also wan't the paging to be intact. I don't want to filter out the removed users after I have received the reslut set, I don't want them to be included at all.
Do you (or anyone else) have any tips on how I can use the query system to do this? Is there a way to chain two queries together? Obviously, there is no property of the ContactRelationQuery to filter our removed users, since it is only concerned with ContactRelations, but if I could create a UserQuery and then chain it to a ContactRelationQuery...?
I'd have to experiment a bit with the query system to see if and how one could do that.
On the other hand I'd still recommend doing this filtering in memory. You could simply get all of the users contacts without paging (or pagesize = maxvalue of int - 1) and then do paging with the LINQ methods Skip and Take. This way you wont have to worry about releasing the cache when a user adds a friend which you'd have to do if you use the query system.
When I request a collection of my friend contacts, I don't want deleted users to be included in the result set. How do I do that?
This is my code right now:
public static ContactRelationCollection GetMyFriends(IUser user, ISite site, int page, int pageSize,
ContactRelationSortOrder sortOrder) {
if (user == null)
throw new ArgumentNullException("user");
if (site == null)
throw new ArgumentNullException("site");
var myPage = mp.MyPageHandler.GetMyPage(user, site);
if (myPage == null || myPage.Contact == null) { return new ContactRelationCollection(); }
return sc.ContactHandler.GetContacts(myPage.Contact, ContactType.Contact, Perspective.ToMe, page, pageSize, sortOrder);
}