Skip to main content

Using the reporting foundation


Describes how to use the reporting client

After following the installation in the previous step you’re ready to consume the reporting client.

Reporting Client is registered in Sitecore IoC Container you can add IReportingClient as a dependency to your service if you’re using Sitecore DI.

Or resolve it via ServiceLocator Sitecore.DependencyInjection:


To query data you can use the method GetFactAsync<TFact>(Action<IFactQueryOptionsBuilder>TFact>> builder) this method accepts a delegate in which it builds the query. Find the example below:

await _reportingClient.GetFactAsync<ProductSales>(cfg =>
                    .ExpandDimension(o => o.Country)
                    .ExpandDimension(o => o.Product);


  • Reporting Client methods are asynchronous

  • The query builder accepts a parameter which is a delegate that builds the query

  • You’ve to pass the connection string name (e.g., reporting) in which you want to query data from (i.e., the database having your SQL Objects)

  • QueryFrom…To will filter data based on the DateTime field in the fact object.

  • ExpandDimension will include the dimension in the result

  • FilterWithKey will filter the result based on the DimensionKey of the dimension


The query must include at least one filter (either dimension or date time) and the connection string name otherwise a ValidationException will be thrown.

Similar to Querying facts, Delete Facts also have the same filters. Find the below examples:

await _reportingClient.DeleteFactsAsync<ProductSales>(cfg =>
                    .DeleteThatHasDimension(o => o.Country)


  • Same filters are used (with different names) in the builder.

  • The delete query builder must include at least one filter too and the connection string

To add or update data you use the method AddOrUpdate async and pass connection string name with a list of the data. Check the example below.

await _reportingClient.AddOrUpdateAsync(_connectionStringName, data)