cs-icon.svg

Contentstack - .Net Delivery SDK

.NET SDK for Contentstack's Content Delivery API

Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest.

For more information, you can check out the GitHub page of our .NET Delivery SDK.

Prerequisites

To get started with C#, you will need:

  • .Net platform
  • IDE (Visual Studio)
  • NuGet.

SDK installation and setup

The .Net SDK provided by contentstack.io is available for Xamarin, Windows Phone and legacy .Net applications. You can integrate contentstack with your application by following these steps.

Open the terminal and install the contentstack module via 'Package Manager' command

PM> Install-Package contentstack.csharp

And via ‘.Net CLI’

dotnet add package contentstack.csharp

To use the module in your application, you need to first Add Namespace to your class

using Contentstack.Core; // ContentstackClient
using Contentstack.Core.Models; // Stack, Query, Entry, Asset, ContentType, ContentstackCollection
using Contentstack.Core.Configuration; // ContentstackOptions

Quickstart in 5 mins

Initialize SDK

You will need to specify the API key, Access token, and Environment Name of your stack to initialize the SDK:

// Initialize the Contentstack 
ContentstackClient client = new ContentstackClient("api_key", "delivery_token", "enviroment_name");

or:

ContentstackOptions options = new ContentstackOptions()
{
	ApiKey = "<api_key>",
	DeliveryToken = "<access_token>",
	Environment = "<environment>"
}
ContentstackClient client = new ContentstackClient(options);

Once you have initialized the SDK, you can start getting content in your app
For Setting other regions:

Refer the below code if you want to use the Europe, Azure North America, or Azure Europe region.

ContentstackOptions options = new ContentstackOptions()
{
	ApiKey = "<api_key>",
	DeliveryToken = "<delivery_token>",
	Environment = "<environment>",
	Region = ContentstackRegion.EU
}
ContentstackClient client = new ContentstackClient(options);

Once you have initialized the SDK, you can start getting content in your app.

For Setting the branch:

If you want to initialize SDK in a particular branch use the code given below:

ContentstackOptions options = new ContentstackOptions() 
{
	ApiKey = "<api_key>",
	DeliveryToken = "<delivery_token>",
	Environment = "<environment>",
	Branch = "<branch>"
};
ContentstackClient client = new ContentstackClient(options);

Basic Queries

Get a Single Entry

To retrieve a single entry from a content type, use the code snippet given below:

ContentstackClient client = new ContentstackClient("api_key", "delivery_token", "enviroment_name");
Entry entry = client.ContentType("product").Entry("entry_uid");
entry.Fetch<Product>().ContinueWith((t) => { 
    if (!t.IsFaulted) { 
        Console.WriteLine("entry:" + t.Result);  
    } 
});

Get Multiple Entries

To retrieve multiple entries of a particular content type, use the code snippet given below:

ContentstackClient client = new ContentstackClient("api_key", "delivery_token", "enviroment_name");
Query query = client.ContentType("product").Query(); 
query.Where("title", "welcome"); 
query.IncludeSchema(); 
query.IncludeCount(); 
query.ToJSON(); 
query.Find<Product>().ContinueWith((t) => { 
    if (!t.IsFaulted) { 
        ContentstackCollection<Product> result = t.Result; 
        Console.WriteLine("result" + result.items); 
    } 
});

Note: By default, the limit for response details per request is 100, with the maximum limit set at 250.

Paginating Responses

In a single instance, the Get Multiple Entries query will retrieve only the first 100 items of the specified content type. You can paginate and retrieve the rest of the items in batches using the skip and limit parameters in subsequent requests.

ContentstackClient client = new ContentstackClient("api_key", "delivery_token", "enviroment_name");
Query query = client.ContentType("blog").Query();
query.Skip(20);
query.Limit(20); 
query.Find<Blog>().ContinueWith((t) => { 
    if (!t.IsFaulted) { 
         ContentstackCollection<Blog> result = t.Result; 
         Console.WriteLine("result" + result); 
    } 
});

ContentstackOptions

Represents a set of options to configure a Stack.
NameTypeDescription

ApiKey (required)

string

The api key used when communicating with the Contentstack API.

AccessToken

string

The access token used when communicating with the Contentstack API.

DeliveryToken (required)

string

The delivery token used when communicating with the Contentstack API.

Environment (required)

string

The environment used when communicating with the Contentstack API.

Region

ContentstackRegion

DB region for your stack. You can choose from four regions namely, NA, EU, Azure NA, and Azure EU.

Default: ContentstackRegion.US

Host

string

The Host used to set host url for the Contentstack API.

Default: cdn.contentstack.io

Version

string

The Version number for the Contentstack API.

Default: v3

Branch

string

The Branch used to set Branch for the Contentstack API.

LivePreview

LivePreviewConfig

The Live preview configuration for the Contentstack API.

LivePreviewConfig

Configuration for enabled live preview to get live content data

NameTypeDescription

Enable

bool

To enable live preview

Default: false

Host

string

Host for getting live preview content

ManagementToken

string

Management Token for the stack to get content

ContentstackRegion

Fields

NameDescription
EU

To specify the EU region.

US

To specify the US region.

AZURE_NA

To specify the AZURE NA region

AZURE_EUTo specify the AZURE EU region

ContentstackCollection

NameTypeDescription

Count

int

The total number of items available.

Items

IEnumerable<T>

The System.Collections.Generic.IEnumerable<T> of items to be serialized from the API response.

Limit

int

The maximum number of items returned in this result.

Skip

int

The number of items skipped in this resultset.

ContentstackException

The ContentstackError class is abstraction of general exception class.

NameTypeDescription

ErrorCode

int

Contentstack error code.

ErrorMessage

string

Contentstack error message

Errors

Dictionary<string, object>

Set of errors in detail.

SyncStack

Represents the result of a sync operation.
NameTypeDescription

Items

IEnumerable<dynamic>

Readonly property contains all the Contents

PaginationToken

string

Readonly property for paginating sync

SyncToken

string

Readonly property to delta sync.

TotalCount

int

Readonly property to check totalCount

SyncType

The different types of items you can request a sync for.

Fields

NameDescription
All

Only published entries and assets

AssetDeleted

Only deleted assets.

AssetPublished

Only published assets.

AssetUnpublished

Only unpublished assets.

ContentTypeDeleted

Only deleted Content-Types entries.

Default

This will bring all published entries and published assets

EntryDeleted

Only deleted entries.

EntryPublished

Only published entries.

EntryUnpublished

Only unpublished entries.

ContentstackClient

Initialize an instance of ‘Stack’
NameTypeDescription

SerializerSettings

JsonSerializerSettings

Gets or sets the settings that should be used for deserialization.

ContentstackClient

Initializes an instance of the ContentstackClient class.

Returns:
Type
ContentstackClient
NameTypeDescription

apiKey

string

API Key of your stack on Contentstack.

deliveryToken

string

Delivery token of your stack on Contentstack.

environment

string

Environment from where you want to fetch content.

host

string

region

ContentstackRegion

version

string

ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
Returns:
Type
ContentstackClient
NameTypeDescription

options

ContentstackOptions

used to get stack details via class ContentstackOptions to create client.

var options = new ContentstackOptions()
 {
       ApiKey = "api_key",
       DeliveryToken = "delivery_token"
       Environment = "environment"
 }
ContentstackClient stack = new ContentstackClient(options);

GetVersion

Get url base version

Returns:
Type
string

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
String url = stack.GetVersion();

Asset

Represents a Asset. Creates Asset Instance.

Returns:
Type
Asset
NameTypeDescription

Uid

string

This is Asset Uid of an Asset.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
Asset asset = stack.Asset("asset_uid");

AssetLibrary

Represents a AssetLibrary. Creates AssetLibrary Instance.
Returns:
Type
AssetLibrary
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = stack.AssetLibrary();

ContentType

Represents a ContentType. Creates ContenntType Instance.
Returns:
Type
ContentType
NameTypeDescription

contentTypeUid

string

ContentType UID.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentType contentType = stack.ContentType("content_type_uid");

GetApplicationKey

Get stack application key

Returns:
Type
string

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
String apiKey = stack.GetApplicationKey();

GetAccessToken

Get stack access token
Returns:
Type
string

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
String accessToken = stack.GetAccessToken();

GetEnvironment

Get stack environment

Returns:
Type
string

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
String environment = stack.GetEnvironment();

GetContentTypes

This method returns comprehensive information of all the content types of a particular stack in your account.

Returns:
Type
Task<System.Collections.IList>
NameTypeDescription

param

Dictionary<string, object>

dictionary of additional parameter

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
var param = new Dictionary<string, object>();
param.Add("include_global_field_schema",true);
param.Add("limit", 10);
param.Add("skip", 10);
param.Add("include_count", "true");
var result = await stack.GetContentTypes(param);

LivePreviewQuery

To add live preview Query for Contentstack preview call

Returns:
Type
string
NameTypeDescription

query

Dictionary<string, string>

Query parameter containing hash and content type UID

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
await client.LivePreviewQueryAsync(new System.Collections.Generic.Dictionary<string, string>()
{
	{"live_preview" , "live_preview_hash_from_url_query" },
	{"content_type_uid", "content_type_uid
" },
	{"entry_uid", "entry_uid
" }
});

RemoveHeader

Remove header key.

Returns:
Type
void
NameTypeDescription

key

string

key to be remove from header

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
stack.RemoveHeader("custom_header_key")

SyncToken

Syncs the token.

Returns:
Type
Task<SyncStack>
NameTypeDescription

SyncToken

string

Sync token.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
SyncStack result = await client.SyncToken("sync_token");

SyncRecursive

Syncs the recursive language.

Returns:
Type
Task<SyncStack>
NameTypeDescription

Locale

string

Locale

SyncType

SyncType

Sync type.

ContentTypeUid

string

Content type uid.

StartFrom

DateTime

Start from.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
SyncStack result = await client.SyncRecursive();

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
SyncStack result = await client.SyncRecursive(SyncType: SyncType.AssetPublished);

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
SyncStack result = await client.SyncRecursive(ContentTypeUid: "source");

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
SyncStack result = await client.SyncRecursive(StartFrom:DateTime.Now);

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
SyncStack result = await client.SyncRecursive(SyncType: SyncType.EntryPublished, ContentTypeUid: "source");

SyncPaginationToken

Syncs the pagination token.

Returns:
Type
Task<SyncStack>
NameTypeDescription

paginationToken

string

Pagination token.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
SyncStack result = await stack.SyncPaginationTokenn("pagination_token");

Asset

Creates an instance of `Assets`.

Retrieves all assets of a stack by default. To retrieve a single asset, specify its UID.

NameTypeDescription

Uid (required)

string

Asset uid

Url

string

Asset URL

Description

string

Asset Description

FileName

string

File name for Asset

FileSize

string

File size of asset

Tags

object[]

Tags assign to asset

SetHeader

To set headers for Contentstack rest calls.

Returns:
Type
Asset
NameTypeDescription

key

string

header name.

value

string

header value against given header name.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").SetHeader("custom_key", "custom_value").fetch();

RemoveHeader

Remove header key.

Returns:
Type
Asset
NameTypeDescription

key

string

key to be remove from header

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").RemoveHeader("header_to_remove").fetch();

GetCreateAt

Get created at time.

Returns:
Type
DateTime

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").fetch();
DateTime date = asset.GetCreateAt()

GetCreatedBy

Get created by user uid

Returns:
Type
string
using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").fetch();
string createBy = asset.GetCreatedBy()

GetUpdateAt

Get updated at time.

Returns:
Type
DateTime

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").fetch();
DateTime date = asset.GetUpdateAt()

GetUpdatedBy

Get Update by user uid

Returns:
Type
string
using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").fetch();
string createBy = asset.GetUpdatedBy()

GetDeleteAt

Get deleted at time.

Returns:
Type
DateTime

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").fetch();
DateTime date = asset.GetDeleteAt()

GetDeletedBy

Get Deleted by user uid

Returns:
Type
string
using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").fetch();
string createBy = asset.GetDeletedBy()

IncludeBranch

Include branch for publish content.
Returns:
Type
Asset

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").IncludeBranch().fetch();

IncludeFallback

Include fallback locale publish content, if specified locale content is not publish.
Returns:
Type
Asset

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").IncludeFallback().fetch();

IncludeMetadata

The includeMetadata method will add the meta information to the response.
Returns:
Type
Asset

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").IncludeMetadata().fetch();

Fetch

fetches the latest version of a specific asset of a particular stack.
Returns:
Type
Task<Asset>

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = await stack.Asset("asset_uid").fetch();

AssetLibrary

Get all asset from Stack

SetHeader

To set headers for Contentstack rest calls.

Returns:
Type
void
NameTypeDescription

key

string

header name.

value

string

header value against given header name.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> asset = await stack.AssetLibrary().SetHeader("custom_key", "custom_value").FindAll();

RemoveHeader

Remove header key.

Returns:
Type
AssetLibrary
NameTypeDescription

key

string

key to be remove from header

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> asset = await stack.AssetLibrary("asset_uid").RemoveHeader("header_to_remove").FindAll();

SortWithKeyAndOrderBy

Sorts the assets in the given order on the basis of the specified field.
Returns:
Type
void
NameTypeDescription

key

string

Field UID

order

string

ordering for sorting from key

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> asset = await stack.AssetLibrary().SortWithKeyAndOrderBy("field_uid", "order").FindAll();

SetLocale

Sets the locale.



Returns:
Type
AssetLibrary
NameTypeDescription

locale

string

Locale to be fetch

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().SetLocale("en-us").FetchAll();

Skip

The number of objects to skip before returning any.

Returns:
Type
AssetLibrary
NameTypeDescription

number

int

No of objects to skip from returned objects.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().Skip(20).FetchAll();

Limit

A limit on the number of objects to return.

Returns:
Type
AssetLibrary
NameTypeDescription

number

int

No of objects to limit.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().Limit(20).FetchAll();

IncludeBranch

Include branch for publish content.
Returns:
Type
AssetLibrary

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().IncludeBranch().FindAll();

IncludeCount

This method also includes the total number of assets returned in the response.



Returns:
Type
AssetLibrary

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().IncludeCount().FindAll();

IncludeFallback

Include fallback locale publish content, if specified locale content is not publish.
Returns:
Type
AssetLibrary

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().IncludeFallback().FindAll();

IncludeMetadata

The includeMetadata method will add the meta information to the response.
Returns:
Type
AssetLibrary

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().IncludeMetadata().FindAll();

Except

Specifies list of field uids that would be excluded from the response.

Returns:
Type
AssetLibrary
NameTypeDescription

fieldUids

System.String[]

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = await stack.AssetLibrary().Except(new String[]{"name", "description"}).FetchAll();

Only

Specifies an array of 'only' keys in BASE object that would be 'included' in the response.

Returns:
Type
AssetLibrary
NameTypeDescription

fieldUid

System.String[]

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = await stack.AssetLibrary().Only(new String[]{"name", "description"}).FetchAll();

IncludeRelativeUrls

This method includes the relative url of assets.



Returns:
Type
Asset

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().IncludeRelativeUrls().FindAll();

FetchAll

Execute a AssetLibrary and Caches its result (Optional)
Returns:
Type
Task<JObject>

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().FetchAll();

Count

Total count of the asset in specified Stack

Returns:
Type
Task<JObject>

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = await stack.AssetLibrary().Count();

ContentType

ContentType provides Entry and Query instance.
NameTypeDescription

ContentTypeId

string

Content type uid

SetHeader

To set headers for Contentstack rest calls.

Returns:
Type
ContentType
NameTypeDescription

key

string

header name.

value

string

header value against given header name.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentType contentType = stack.ContentType("content_type_uid").SetHeader("custom_key", "custom_value");

RemoveHeader

Remove header key.

Returns:
Type
ContentType
NameTypeDescription

key

string

key to be remove from header

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentType contentType = await stack.ContentType("content_type_uid").RemoveHeader("header_to_remove");

Fetch

This method returns the complete information, of a specific content type.



Returns:
Type
Task<Newtonsoft.Json.Linq.JObject>
NameTypeDescription

param

Dictionary<Object>

Dictionary of additional parameter

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
var param = new Dictionary<string, object>();
param.Add("include_global_field_schema",true);
var result = await stack.ContentType("content_Type_uid").Fetch(param);

Entry

Represents a Entry. Create Entry Instance.



Returns:
Type
Entry
NameTypeDescription

entryUid

string

Set entry uid.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = stack.ContentType("content_Type_uid").Entry("entry_uid");

Query

Represents a Query Create Query Instance.

Returns:
Type
Entry

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Query query = stack.ContentType("content_Type_uid").Query();

Entry

An initializer is responsible for creating Entry object.
NameTypeDescription

Metadata

Dictionary<string, object>

Set key/value attributes of Metadata.

Object

Dictionary<string, object>

Set key/value attributes of an current entry instance.

Tags

object[]

Set array of Tags

Title

string

Title of an entry

Uid

string

This is Entry Uid of an entry.

GetContentType

Get contentType name.

Returns:
Type
string

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
string contentType = stack.ContentType("content_Type_uid").Entry("entry_uid").GetContentType();

GetUid

Get entry uid

Returns:
Type
string

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
var uid = entry.GetUid();

GetTitle

Get entry title

Returns:
Type
string

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
var title = entry.GetTitle();

GetTags

Returns tags of this entry.

Returns:
Type
object[]

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
var tags = entry.GetTags();

GetMetadata

Get metadata of entry.



Returns:
Type
Dictionary<string, object>

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
var metadata = entry.GetMetadata();

GetHTMLText

Get html text for markdown data type

Returns:
Type
string
NameTypeDescription

markdownKey

string

field_uid as key.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
var result = entry.GetHTMLText("markdownKey");

GetMultipleHTMLText

Get html text for markdown data type which is multiple true

Returns:
Type
List<string>
NameTypeDescription

markdownKey

string

Field_uid as key.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
List<string> metadata = entry.GetMultipleHTMLText("markdown_field_uid");

GetCreateAt

Get value of creation time of entry.

Returns:
Type
DateTime

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
DateTime datetime = entry.GetCreateAt();

GetCreatedBy

Get uid who created this entry.

Returns:
Type
string

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
string createdBy = entry.GetCreatedBy();

GetUpdateAt

Get value of updating time of entry.

Returns:
Type
DateTime

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
DateTime datetime = entry.GetUpdateAt();

GetUpdatedBy

Get uid who updated this entry.



Returns:
Type
string

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
string updatedBy = entry.GetUpdatedBy();

GetDeletedAt

Get value of deleting time of entry.

Returns:
Type
DateTime

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
DateTime datetime = entry.GetDeletedAt();

GetDeletedBy

Get uid who created this entry.

Returns:
Type
string

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
string deletedBy = entry.GetDeletedBy();

Get

Get object value for key.

Returns:
Type
Object
NameTypeDescription

key

Object

Key to get value

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Entry>();
Object value = entry.Get("key");

SetCachePolicy

To set cache policy using Entry instance.

Returns:
Type
Entry
NameTypeDescription

cachePolicy

CachePolicy

CachePolicy instance

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_type_uid").Entry("entry_uid").SetCachePolicy(CachePolicy.NetworkElseCache).Fetch<Entry>();

SetHeader

To set headers for Contentstack rest calls.

Returns:
Type
Entry
NameTypeDescription

key

string

header name.

value

string

header value against given header name.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_type_uid").Entry("entry_uid").SetHeader("custom_key", "custom_value").Fetch();

RemoveHeader

Remove header key.

Returns:
Type
Entry
NameTypeDescription

key

string

key to be remove from header

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_type_uid").Entry("entry_uid").RemoveHeader("header_to_remove").fetch();

SetLocale

Sets the locale.

Returns:
Type
Entry
NameTypeDescription

Locale

string

Locale to fetch entry

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_type_uid").Entry("entry_uid").SetLocale("en-us").Fetch<Entry>();

SetUid

Assigns a uid to current instance of an entry.

Returns:
Type
Entry
NameTypeDescription

uid

string

Uid for entry to fetch

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.Entry().SetUid("entry_uid").SetLocale("en-us").Fetch<Entry>();

SetTags

Assign a tag(s) for this Entry.

Returns:
Type
Entry
NameTypeDescription

tags

string[]

Collection of tags.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.Entry("entry_uid").SetTags(new List<string>() {
	"tag_1"
}).Fetch<Entry>();

IncludeReferenceContentTypeUID

This method also includes the content type UIDs of the referenced entries returned in the response.

Returns:
Type
Entry

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").IncludeReferenceContentTypeUID().Fetch<Entry>();

IncludeReference

Add a constraint that requires a particular reference key details.



Returns:
Type
Entry
NameTypeDescription

referenceFields

string[]

Array key that to be constrained.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").IncludeReference(new String[]{"reference_uid_1", "reference_uid_2"}).Fetch<Entry>();

IncludeReference

Add a constraint that requires a particular reference key details.



Returns:
Type
Entry
NameTypeDescription

referenceField

String

Key that to be constrained.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").IncludeReference("reference_uid_1").Fetch<Entry>();

IncludeOnlyReference

Specifies an array of except keys that would be excluded in the response.



Returns:
Type
Entry
NameTypeDescription

keys

string[]

Array of the only reference keys to be included in response.

referenceKey

string

Key who has reference to some other class object.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").IncludeOnlyReference(new String[]{"name", "description"},"referenceUid").Fetch<Entry>();

IncludeExceptReference

Specifies an array of except keys that would be excluded in the response.



Returns:
Type
Entry
NameTypeDescription

keys

string[]

Array of the except reference keys to be excluded in response.

referenceKey

string

Key who has reference to some other class object.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").IncludeExceptReference(new String[]{"name", "description"},"referenceUid").Fetch<Entry>();

IncludeEmbeddedItems

Include Embedded Objects (Entries and Assets) along with entry/entries details.



Returns:
Type
Entry

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").IncludeEmbeddedItems().Fetch<Entry>();

IncludeFallback

Include fallback locale publish content, if specified locale content is not publish.



Returns:
Type
Entry

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").IncludeFallback().Fetch<Entry>();

IncludeMetadata

The includeMetadata method will add the meta information to the response.



Returns:
Type
Entry

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").IncludeMetadata().Fetch<Entry>();

IncludeBranch

Include branch for publish content.

Returns:
Type
Entry

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").IncludeBranch().Fetch<Entry>();

Only

Specifies an array of 'only' keys in BASE object that would be 'included' in the response.

Returns:
Type
Entry
NameTypeDescription

fieldUid

System.String[]

Array of the only reference keys to be included in response.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = await stack.Entry().Only(new String[]{"name", "description"}).Fetch();

Except

Specifies list of field uids that would be excluded from the response.

Returns:
Type
Entry
NameTypeDescription

fieldUids

System.String[]

Field uid which get excluded from the response.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = await stack.Entry("entry_uid").Except(new String[]{"name", "description"}).Fetch();

ToJson

Get key/value pairs in json of current instance.



Returns:
Type
JObject

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Entry entry = await stack.ContentType("content_Type_uid").Entry("entry_uid").IncludeReferenceContentTypeUID().Fetch<Entry>();
JObject jObject = entry.ToJson();

Fetch

Fetches the latest version of the entries from Contentstack.io content stack

Returns:
Type
Task<T>

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Product product = await stack.ContentType("content_Type_uid").Entry("entry_uid").Fetch<Product>();

Query

A class that defines a query that is used to query for Entry instance.

AddQuery

Add a custom query against specified key.

Returns:
Type
Query
NameTypeDescription

key

string

field uid.

value

string

field value

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().AddQuery("key", "value").Find<Entry>();

IncludeCount

Retrieve count and data of objects in result.

Returns:
Type
Query

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().IncludeCount().Find<Entry>();

IncludeBranch

Include branch for publish content.

Returns:
Type
Query

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().IncludeBranch().Find<Entry>();

IncludeFallback

Include fallback locale publish content, if specified locale content is not publish.



Returns:
Type
Query

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> entry = await stack.ContentType("content_Type_uid").Query().IncludeFallback().Find<Entry>();

IncludeMetadata

The includeMetadata method will add the meta information to the response.



Returns:
Type
Query

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> entry = await stack.ContentType("content_Type_uid").Query().IncludeMetadata().Find<Entry>();

IncludeEmbeddedItems

Include Embedded Objects (Entries and Assets) along with entry/entries details.



Returns:
Type
Query

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> entry = await stack.ContentType("content_Type_uid").Query().IncludeEmbeddedItems().Find<Entry>();

IncludeOnlyReference

Specifies an array of except keys that would be excluded in the response.



Returns:
Type
Query
NameTypeDescription

keys

string[]

Array of the only reference keys to be included in response.

referenceKey

string

Key who has reference to some other class object.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> entry = await stack.ContentType("content_Type_uid").Query().IncludeOnlyReference(new String[]{"name", "description"},"referenceUid").Find<Entry>();

IncludeExceptReference

Specifies an array of except keys that would be excluded in the response.



Returns:
Type
Query
NameTypeDescription

keys

string[]

Array of the except reference keys to be excluded in response.

referenceKey

string

Key who has reference to some other class object.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> entry = await stack.ContentType("content_Type_uid").Query().IncludeExceptReference(new String[]{"name", "description"},"referenceUid").Find<Entry>();

IncludeReference

Add a constraint that requires a particular reference key details.



Returns:
Type
Query
NameTypeDescription

referenceField

String

Key that to be constrained.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> entry = await stack.ContentType("content_Type_uid").Query().IncludeReference("reference_uid_1").Find<Entry>();

IncludeReferenceContentTypeUID

This method also includes the content type UIDs of the referenced entries returned in the response.

Returns:
Type
Query

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().IncludeReferenceContentTypeUID().Find<Entry>();

IncludeReference

Add a constraint that requires a particular reference key details.



Returns:
Type
Query
NameTypeDescription

referenceFields

string[]

Array key that to be constrained.

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().IncludeReference(new String[]{"reference_uid_1", "reference_uid_2"}).Find<Entry>();

ReferenceIn

Retrieve entries based reference in query





Returns:
Type
Query
NameTypeDescription

key

string

They key to constraint on

query

Query

Query object

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentType contentTypeObj = stack.ContentType("contentType_id");
Query query = contentTypeObj.Query();
query.Where("email_address","content@email.com");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().ReferenceIn("user", query).Find<Entry>();

ReferenceNotIn

Retrieve entries based reference not in query





Returns:
Type
Query
NameTypeDescription

key

string

The key to constraint on

query

Query

Query object

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentType contentTypeObj = stack.ContentType("contentType_id");
Query query = contentTypeObj.Query();
query.Where("email_address","content@email.com");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().ReferenceNotIn("user", query).Find<Entry>();

Regex

Add a regular expression constraint for finding string values that match the provided regular expression.
Returns:
Type
Query
NameTypeDescription

key

string

The key to be constrained.

regex

string

The regular expression pattern to match.

modifiers

string

Any of the following supported Regular expression modifiers.

  • use i for case-insensitive matching.
  • use m for making dot match newlines.
  • use x for ignoring whitespace in regex

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> entry = await stack.ContentType("content_type_uid").Query().Regex("name", "^browser").Find<Entry>();

using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> entry = await stack.ContentType("content_type_uid").Query().Regex("name", "^browser", "i").Find<Entry>();

RemoveQuery

Remove provided query key from custom query if exist.

Returns:
Type
Query
NameTypeDescription

key

string

Query name to remove.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_type_uid").Query().RemoveQuery("query_key").Find<Entry>();

SetCachePolicy

To set cache policy using Query instance.

Returns:
Type
Query
NameTypeDescription

cachePolicy

CachePolicy

CachePolicy instance

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_type_uid").Query().SetCachePolicy(CachePolicy.NetworkElseCache).Find<Entry>();

SetLocale

Sets the locale.

Returns:
Type
Query
NameTypeDescription

Locale

string

Locale to fetch entry

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_type_uid").Query().SetLocale("en-us").Find<Entry>();

SetHeader

To set headers for Contentstack rest calls.

Returns:
Type
Query
NameTypeDescription

key

string

header name.

value

string

header value against given header name.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_type_uid").Query().SetHeader("custom_key", "custom_value").Find<Entry>();

RemoveHeader

Remove header key.

Returns:
Type
Query
NameTypeDescription

key

string

key to be remove from header

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> entry = await stack.ContentType("content_type_uid").Query().RemoveHeader("header_to_remove").Find<Entry>();

WhereTags

Include tags with which to search entries.







Returns:
Type
Query
NameTypeDescription

tags (required)

string[]

Array of tags you want to match in the entries

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().WhereTags(new String[] {"tag_1", tag_2}).Find<Entry>();

Skip

The number of objects to skip before returning any.









Returns:
Type
Query
NameTypeDescription

number

string

No of objects to skip.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Skip(20).Find<Entry>();

Limit

A limit on the number of objects to return.







Returns:
Type
Query
NameTypeDescription

number

string

No of objects to limit.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Limit(20).Find<Entry>();

Ascending

Sort the results in ascending order with the given key.







Returns:
Type
Query
NameTypeDescription

fieldUid

string

The key to order by.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Ascending("name").Find<Entry>();

Descending

Sort the results in descending order with the given key.







Returns:
Type
Query
NameTypeDescription

fieldUid

string

The key to order by.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Descending("name").Find<Entry>();

And

Combines all the queries together using AND operator





Returns:
Type
Query
NameTypeDescription

queryObjects

List<Query>

List of Query instances on which AND query executes.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentType contentTypeObj = stack.ContentType("contentType_id");
Query query1 = contentTypeObj.Query();
query1.Where("username","content");
Query query2 = contentTypeObj.Query();
query2.Where("email_address","content@email.com");
List<Query> queryList = new List<Query>();
queryList.Add(query1);
queryList.Add(query2);
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().And(queryList).Find<Entry>();

Or

Add a constraint to fetch all entries which satisfy any queries.





Returns:
Type
Query
NameTypeDescription

queryObjects

List<Query>

List of Query instances on which OR query executes.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentType contentTypeObj = stack.ContentType("contentType_id");
Query query1 = contentTypeObj.Query();
query1.Where("username","content");
Query query2 = contentTypeObj.Query();
query2.Where("email_address","content@email.com");
List<Query> queryList = new List<Query>();
queryList.Add(query1);
queryList.Add(query2);
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Or(queryList).Find<Entry>();

Except

Specifies list of field uids that would be excluded from the response.





Returns:
Type
Query
NameTypeDescription

fieldUid

string[]

field uid which get excluded from the response.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Except(new String[] {"name", description }).Find<Entry>();

Only

Specifies an array of 'only' keys in BASE object that would be 'included' in the response.





Returns:
Type
Query
NameTypeDescription

fieldUid

string[]

Array of the 'only' keys to be included in response.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Only(new String[] {"name", description }).Find<Entry>();

Exists

Add a constraint that requires, a specified key exists in response.



Returns:
Type
Query
NameTypeDescription

key

string

The key to be constrained.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Exist("title").Find<Entry>();

NotExists

Add a constraint that requires, a specified key does not exists in response.



Returns:
Type
query
NameTypeDescription

key

string

The key to be constrained.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().NotExist("title").Find<Entry>();

NotEqualTo

Add a constraint to the query that requires a particular key's entry to be not equal to the provided value.











Returns:
Type
Query
NameTypeDescription

key

string

the key to be constrained.

value

Object

The object that must not be equaled.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().NotEqualTo("title", "Demo").Find<Entry>();

Where

Add a constraint to the query that requires a particular key entry's value not be contained in the provided array.









Returns:
Type
Query
NameTypeDescription

key

string

the key to be constrained.

value

Object

Field value which get included from the response.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Where("title", "Demo").Find<Entry>();

NotContainedIn

Add a constraint to the query that requires a particular key entry's value not be contained in the provided array.









Returns:
Type
Query
NameTypeDescription

key

string

the key to be constrained.

value

Object[]

The list of values the key object should not be.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().NotContainedIn("title", new Object[]{ "Demo", "Welcome"}).Find<Entry>();

ContainedIn

Add a constraint to the query that requires a particular key's entry to be contained in the provided array.







Returns:
Type
Query
NameTypeDescription

key

string

the key to be constrained.

value

Object[]

The possible values for the key's object.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().ContainedIn("title", new Object[]{ "Demo", "Welcome"}).Find<Entry>();

LessThanOrEqualTo

Add a constraint to the query that requires a particular key entry to be less than or equal to the provided value.





Returns:
Type
Query
NameTypeDescription

key

string

the key to be constrained.

value

Object

The value that provides an upper bound or equal.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().LessThanOrEqualTo("age", 20).Find<Entry>();

LessThan

Add a constraint to the query that requires a particular key entry to be less than the provided value.





Returns:
Type
Query
NameTypeDescription

key

string

the key to be constrained.

value

Object

The value that provides an upper bound.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().LessThan("age", 20).Find<Entry>();

GreaterThanOrEqualTo

Add a constraint to the query that requires a particular key entry to be greater than or equal to the provided value.





Returns:
Type
Query
NameTypeDescription

key

string

the key to be constrained.

value

Object

The value that provides a lower bound or equal.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().GreaterThanOrEqualTo("age", 20).Find<Entry>();

GreaterThan

Add a constraint to the query that requires a particular key entry to be greater than the provided value.



Returns:
Type
Query
NameTypeDescription

key

string

the key to be constrained.

value

Object

The value that provides an lower bound.

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().GreaterThan("age", 20).Find<Entry>();

Find

Execute a Query and Caches its result (Optional)

Returns:
Type
Task<ContentstackCollection<T>>

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Find<Entry>();

FindOne

Execute a Query and Caches its result (Optional)

Returns:
Type
Task<ContentstackCollection<T>>

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().FindOne<Entry>();

Count

Retrieve only count of entries in result.

Returns:
Type
Task<JObject>

using Contentstack.Core; 
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentstackCollection<Entry> collection = await stack.ContentType("content_Type_uid").Query().Count();