I am trying top Get all contacts from a Google account using the .Net API.
Case 1:
var cr = new ContactsRequest(settings);
var feed = cr.GetContacts();
When I do something like the previous code segment it brings me all the contacts but it also brings the Other Contacts for the same user. This can be very costly in terms of performance. I then filter locally the contacts and keep only the ones that I am interested in but the damage is already done.
Case 2:
var cr = new ContactsRequest(settings);
var groupFeed = cr.GetGroups();
foreach (var group in groupFeed.Entries.ToList()) {
var query = new ContactsQuery(ContactsQuery.CreateContactsUri("default")) {Group = group.Id};
var contactFeed = cr.Get<Contact>(query);
contactsList.AddRange(contactFeed.Entries.ToList());
}
In this case iterate through the Groups in the account and get the contacts for each group. Other Contacts are not a group, so I manage to escape them. By default when a user creates a contact in whatever Group, the contact is added to this Group and to the "Master Group" which is My Contacts. So a contact may be part of one (My Contacts - if created there) or more groups (if contact created elsewhere). However, the user can manually remove the contact from My Contacts and keep it only in another Group.
- If I iterate through all groups and then filter locally I will fetch all contacts but most probably more than one time => poor performance.
- If I get all contacts from My Contacts I risk of missing some of them.
So, the optimal solution to the above would be to fetch all contacts excluding Other Contacts. Could someone propose a solution (maybe add some parameters to the ContactsQuery or something)?