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

Overview of Graph C# SDK

Learn how the Optimizely Graph C# SDK enables strongly typed, LINQ-style querying of content from Optimizely Content Graph in .NET applications.

👍

Early access preview

This content is an early access preview and may change before general availability. Use the thumbs up or down at the end of this article to share feedback and help shape the final release.

The Graph C# SDK provides a strongly typed, LINQ-style API for querying content from Optimizely GraphQL 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 GraphQL documentation, which covers indexing, schema design, and search architecture. If you are migrating from Optimizely Find to Optimizely Graph queries, review the Optimizely Graph migration guides for guidance on feature migration, feature comparison and best practices.

Example query

The example query executes 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 for querying content from Optimizely Graph.
Optimizely.Graph.AspNetCoreAdds ASP.NET Core–specific integrations for search tracking and click-through analytics.

Guides

Follow the guides to learn more on how to use the C# SDK

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

Query patterns

Pattern guideWhat it covers
FilteringHow to filter for String, numeric, boolean, and date filters; AND/OR logic.
OrderingHow to apply OrderBy, ThenBy, ascending and descending.
SearchingLearn more about Full-text search, field-specific search, relevance boosting.
PaginationLearn how to implement Skip/Limit for large result sets.
Include totalLearn about Total result count for page navigation.
AggregationsLearn about Facets and counts for category filtering.
Decay functionsLearn about recency-based relevance scoring.
SynonymsLearn how to use Synonym expansion via slot-based filters.
Pinned resultsLearn how to promote specific items to the top of search results.

Reference