Changes to xConnect Client API in Sitecore 10

During an upgrade of my Marketing Automation custom activity demo code to version 10, Visual Studio flagged a warning that the xConnect Client getAsync method was marked as obsolete when passing in ContactExpandOptions.

The warning was:

XdbContext.GetAsync(IEntityReference, ExpandOptions)' is obsolete: 'Please use overload that accepts ExecutionOptions parameter.'

It turns out that, as of Sitecore 10, when doing a getAsync() or get() using the xConnectClient you need to pass an object that extends ExecutionOptions such as Sitecore.XConnect.ContactExecutionOptions. These are:

  • ContactExecutionOptions
  • DeviceProfileExecutionOptions
  • InteractionExecutionOptions

As an example, retrieving a contact changes from:

var contactTask = client.GetAsync(reference, new ContactExpandOptions(personalInfoFacetKey));


var contactTask = client.GetAsync(reference, new ContactExecutionOptions(new ContactExpandOptions(personalInfoFacetKey)));

See Sitecore xConnect Client API docs for more.