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 previewThis 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.
| Package | Purpose |
|---|---|
Optimizely.Graph.Cms.Query | Provides the core Graph C# query API for querying content from Optimizely Graph. |
Optimizely.Graph.AspNetCore | Adds 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
| Guide | What it covers |
|---|---|
| Quick start | Install, configure, and run your first query |
| Authentication | Single Key vs. Basic Auth, security best practices |
| Search tracking | Track which results users click, Beacon API integration |
Query patterns
| Pattern guide | What it covers |
|---|---|
| Filtering | How to filter for String, numeric, boolean, and date filters; AND/OR logic. |
| Ordering | How to apply OrderBy, ThenBy, ascending and descending. |
| Searching | Learn more about Full-text search, field-specific search, relevance boosting. |
| Pagination | Learn how to implement Skip/Limit for large result sets. |
| Include total | Learn about Total result count for page navigation. |
| Aggregations | Learn about Facets and counts for category filtering. |
| Decay functions | Learn about recency-based relevance scoring. |
| Synonyms | Learn how to use Synonym expansion via slot-based filters. |
| Pinned results | Learn how to promote specific items to the top of search results. |
Reference
- Error reference — HTTP error codes, causes, and fixes
Updated 13 days ago
