我们正在使用图形api来获取联系人。但是对于特殊测试帐户,Graph API
的结果与people panel of the Office365
所示的结果不匹配。
Screen shot
此外,我们通过运行脚本来导入联系人列表两次,这会导致重复的联系人数据确实具有不同的id
字段。而且我们无法从people panel of the Office365
中找到重复的副本。
那么我们如何获得与联系人数为5517的屏幕截图相同的结果。
答案 0 :(得分:0)
根据您的描述,您想要找到重复的。可能没有API可以执行此操作。如果您要查找联系人的重复列表,我们可以在the MS User Voice中提交功能。
我还有另一种解决方案,可以通过编码来实现。简单的代码如下:
var contacts = await _serviceClient.Me.Contacts.Request().GetAsync();
// Get duplicate list of contacts through the name of the contact person
var result = from contact in contacts.CurrentPage
group contact by contact.DisplayName into dupContacts
where dupContacts.Count() > 1
select dupContacts;
如果您想使用代码来区分联系人,我们可以使用以下代码:
var contacts = await _serviceClient.Me.Contacts.Request().GetAsync();
var result = contacts.CurrentPage.Distinct(new ContactComparer())
还有ContactComparer
这样的类:
public class ContactComparer : IEqualityComparer<Contact>
{
public bool Equals(Contact x, Contact y)
{
if (string.CompareOrdinal(x.DisplayName, y.DisplayName) == 0)
{
return true;
}
else
{
return false;
}
}
}