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. That resource covers indexing, schema design, and search architecture. To migrate from Search & Navigation to Optimizely Graph, review the migration guides for feature mapping and best practices.
Example query
This example demonstrates how a single query chains filtering, searching, sorting, and pagination. It searches BlogPostPage content for optimizely, filters by the Tutorials category, and sorts by publish date descending. The query returns 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 to retrieve content from Optimizely Graph. |
Optimizely.Graph.AspNetCore | Adds 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:
| Guide | What it covers |
|---|---|
| Quick start | Install, configure, and run your first query |
| Authentication | Single Key versus Basic authentication and security best practices |
| Search tracking | Track which results users click, Beacon API integration |
Query patterns
Each pattern guide demonstrates a specific query operation with code examples and usage scenarios.
| Pattern guide | What it covers |
|---|---|
| Filtering | Filter by string, numeric, boolean, and date values, and combine them with AND or OR logic. |
| Ordering | Apply OrderBy and ThenBy for ascending or descending sorts. |
| Searching | Run full-text search, field-specific search, and relevance boosting. |
| Pagination | Implement Skip and Limit for large result sets. |
| Include total | Return the total result count for page navigation. |
| Aggregations | Use facets and counts for category filtering. |
| Decay functions | Apply recency-based relevance scoring. |
| Synonyms | Apply synonym expansion through slot-based filters. |
| Pinned results | Promote specific items to the top of search results. |
Reference
For HTTP error codes, causes, and fixes, see the Error reference.
Updated 13 days ago
