Get contacts
Use the client.Get<Contact>() or client.GetAsync<Contact> method to retrieved by ID or by an identifier. You can retrieve a single contact or a batch of contacts.
Get contact by ID
The following example demonstrates how to retrieve a single contact by ID:
Get contact by identifier
The following examples demonstrate how to retrieve a contact by an identifier. Use the same method for both known and anonymous identifiers. Refer to the contacts overview topic for more information about identifiers
Both source and identifier are case sensitive.
Get contact by alias identifier
All contacts have an alias identifier that consist of a GUID and source defined by Sitecore.XConnect.Constants.AliasIdentifierSource.
Use the .GetAlias() extension on the Contact class to retrieve a contact’s alias identifier.
Get multiple contacts
You can use .GetAsync<Contact>() and .Get<Contact>() methods to retrieve multiple contacts by passing in an array of contact references. Contacts are returned as a single batch. As shown in the following example, it is possible to retrieve contacts using a mixture of IDs and identifiers:
xConnect returns a IEntityLookupResult<Contact> for each operation even if the contact was not found. If the contact exists, the Exists property will be set to true and the contact can be accessed via the Entity property. If the contact exists but could not be retrieved, inspect the Exception property for more information.
If multiple contact references refer to the same contact, xConnect cannot consolidate the list, and returns the contact multiple times.
Get contact facets and related interactions
By default, contacts are returned without facets or related interactions. Use expand options to determine which facets and which range of related interactions should be returned.