Skip to main content
C#
1
2
3
4
5
6
7
8
// Get a entry model by id. T Get<T>(string id); // List entry models for a given content type. PagedList<T> List<T>(string contentTypeId); // Search entry models PagedList<T> Search<T>(Query query)

Basic example

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
namespace MovieDb.Models { public class Movie { // Defined as title in the Content type. public string Title { get; set; } // Defined as overview in the Content type. public string Overview { get; set; } // Defined as releaseDate in the Content type. public DateTime ReleaseDate { get; set; } } }
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
using Zengenti.Contensis.Delivery; using MovieDb.Models; // Import the models // Create a client to allow access to the content var client = ContensisClient.Create(); // Get the entry as a Movie type var movie = client.Entries.Get<Movie>("c1f27b57-c750-4feb-bd12-004ee651e796"); // Access the fields for the entry as typed properties var title = movie.Title; var overview = movie.Overview; var releaseDate = movie.ReleaseDate;

Linked entries and assets

Example

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace MovieDb.Models { public class Person { public string Name { get; set; } public string DateOfBirth { get; set; } } public class Movie { public string Title { get; set; } public string Overview { get; set; } public DateTime ReleaseDate { get; set; } // Return the director as a Person instance. public Person Director { get; set; } // Return the actors as a list of Person instances. public List<Person> { get; set; } } }
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
using Zengenti.Contensis.Delivery; using MovieDb.Models; // Import the models // Create a client to allow access to the content. var client = ContensisClient.Create(); // Get the entry as a Movie type. A link depth needs to be specified to resolve the linked entries. var movie = client.Entries.Get<Movie>("c1f27b57-c750-4feb-bd12-004ee651e796", language = null, linkDepth = 1); // Get the directors name. var directorName = movie.Director.Name; // Get the actors count. var actors = movie.Actors.Count;

EntryModel & ComponentModel base classes

C#
1
2
3
public class Movie: EntryModel { }
C#
1
2
3
4
5
6
7
8
public class Movie: EntryModel { // Other properties ... // public Person Director => Resolve<Person>("director"); }
C#
1
2
3
4
5
6
7
8
public class Movie: EntryModel { // Other properties ... // Return a list of the typed model public List<Person> Actors => ResolveList<Person>("actors"); }
C#
1
2
3
4
5
6
7
8
public class Movie: EntryModel { // Other properties ... // public Image CoverImage => Resolve<Image>("coverImage"); }
C#
1
2
3
4
5
6
7
8
public class Movie: EntryModel { // Other properties ... // public List<Image> FeatureImages => Resolve<Image>("featureImages"); }
C#
1
2
3
4
5
6
7
8
public class Movie: EntryModel { // Other properties ... // Return the producer as the built-in entry type public Entry Producer => Resolve<Entry>("producer"); }
C#
1
2
3
4
5
6
7
8
9
10
11
// Get an entry model var movie = client.Entries.Get<Movie>("c1f27b57-c750-4feb-bd12-004ee651e796"); // Get the entry id var entryId = movie.Sys.Id; // Get the entry language var language = movie.Sys.Language; // Get the version no. var versionNo = movie.Sys.Version.VersionNo;
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Create a ComponentModel based class public class FilmingLocation: ComponentModel { // The name of the location public string Name { get; set;} // The geographic coordinates public Location Location {get; set;} // Resolve the location image on-demand public Image LocationImage => Resolve<Image>("locationImage"); } // Get an entry model var movie = client.Entries.Get<Movie>("c1f27b57-c750-4feb-bd12-004ee651e796"); // Access the component var filmingLocation = movie.Get<FilmingLocation>("filmingLocation"); // The image is resolved when accessed Image image = filmingLocation.LocationImage

Still need help?

New support request