Skip to main content

Value()

C#
1
2
3
public dynamic Value(bool autoResolve = true) { }
C#
1
2
3
4
5
// Get the ComposedField instance var composed = film.Get<ComposedField>("synopsis"); // Get the first item value dynamic quote = composed[0].Value();

Value<T>()

C#
1
2
3
public T Value<T>() { }
C#
1
2
3
4
5
// Get the ComposedField instance var composed = film.Get<ComposedField>("synopsis"); // Get the first item value as a Quote object var quote = composed[0].Value<Quote>();

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Zengenti.Contensis.Delivery // Create an api client var client = ContensisClient.Create(); // Get an entry var filmEntry = client.Entries.Get("1fdbdac6-a8fe-4a86-9c1a-42238fcb47f1"); // Get the synopsis field as a ComposedField type var synopsis = filmEntry.Get<ComposedField>("synopsis"); <div> @foreach(ComposedFieldItem item in synopsis) { // Loop through the ComposedFieldItems in the ComposedField and render the items if (item.Type == "mainHeading") { <h1>@item.Value()</h1> } if (item.Type == "subHeading") { <h2>@item.Value()</h2> } if (item.Type == "markup") { <div>@Html.Raw(item.Value<string>())</div> } if (item.Type == "quote") { var filmQuote = item.Value<Quote>(); <blockquote cite="@filmQuote.Source"> @filmQuote.Text </blockquote> } } </div>

Still need help?

New support request