Skip to content

Resolvers

The DataverseService supports connecting to multiple Dataverse instances. In order to determine which service to use when requesting an IDataverseService from the dependency injection container, there are "resolvers" that can be registered.

Tip

Using resolvers is only necessary if you are connecting to multiple Dataverse instances.

Conceptually, a resolver is very simple. It looks at an incoming request (e.g. an HTTP request to an ASP.Net Web API), looks at the request, and determines if there is a valid Organization ID. If there is, it uses it.

For example, in the Imprevis.Dataverse.Service.Resolvers.Http package, there is a ResolveByQueryString resolver. This resolver analyzes the query string for an Organization ID.

services
  .AddDataverseServices()
  .ResolveByQueryString("organizationId");

For any incoming request, if there is an organizationId query string parameter, it will read it and retrieve the corresponding IDataverseService from the DataverseServiceFactory.

It's possible to register multiple resolvers. They are checked in the same order they are registered.

collection
  .AddDataverseServices()
  .ResolveByQueryString("organizationId")
  .ResolveByRouteValue("organizationId")
  .ResolveByCookie("X-OrganizationId");

This will first check for the query string. If it doesn't exist, then it will check for a route value. If that doesn't exist, then it will check for a cookie. If none of those exist (or none resolve to a valid Guid), then a DataverseServiceNotResolvedException will be thrown.