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.
| 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
| 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 6 days ago
