HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Overview of Graph C# SDK

The Optimizely Graph C# (.NET) SDK enables strongly typed, LINQ-style querying of content from Optimizely Graph in .NET applications.

The Graph C# SDK provides a strongly typed, LINQ-style API for querying content from Optimizely Graph in .NET applications. Instead of writing raw GraphQL queries, chain C# methods to filter, search, sort, paginate, and shape results.

For foundational concepts and platform capabilities, see the Optimizely Graph documentation, which covers indexing, schema design, and search architecture. If you are migrating from Optimizely Search & Navigation to Optimizely Graph queries, review the migration guides for feature mapping, comparisons, and best practices.

Example query

The following example runs a full-text search for optimizely on BlogPostPage content, filters by the Tutorials category, sorts by publish date descending, paginates the first 10 results, and includes the total match count.

var result = await _graphClient
    .QueryContent<BlogPostPage>()
    .SearchFor("optimizely")
    .UsingFullText()
    .Where(x => x.BlogCategory == "Tutorials")
    .OrderBy(x => x.StartPublish, OrderDirection.Descending)
    .Skip(0)
    .Limit(10)
    .IncludeTotal()
    .GetAsContentAsync();

NuGet packages

Install the following NuGet packages to enable the C# SDK.

PackagePurpose
Optimizely.Graph.Cms.QueryProvides the core Graph C# query API to retrieve content from Optimizely Graph.
Optimizely.Graph.AspNetCoreAdds ASP.NET Core integrations for search tracking and click-through analytics.

Guides for the C# SDK

The following guides explain how to use the C# SDK:

GuideWhat it covers
Quick startInstall, configure, and run your first query
AuthenticationSingle Key versus Basic authentication and security best practices
Search trackingTrack which results users click, Beacon API integration

Query patterns

Pattern guideWhat it covers
FilteringFilter by string, numeric, boolean, and date values, and combine them with AND or OR logic.
OrderingApply OrderBy and ThenBy for ascending or descending sorts.
SearchingRun full-text search, field-specific search, and relevance boosting.
PaginationImplement Skip and Limit for large result sets.
Include totalReturn the total result count for page navigation.
AggregationsUse facets and counts for category filtering.
Decay functionsApply recency-based relevance scoring.
SynonymsApply synonym expansion through slot-based filters.
Pinned resultsPromote specific items to the top of search results.

Reference

For HTTP error codes, causes, and fixes, see the Error reference.