Table of Contents

Interface IDynamicStack

Namespace
ToSic.Sxc.Data
Assembly
ToSic.Sxc.dll

This is a dynamic object which contains multiple dynamic objects (Sources). It will try to find a value inside each source in the order the Sources are managed.

[PublicApi]
public interface IDynamicStack : ICanDebug
Inherited Members

Remarks

New in 12.02

Properties

AnyProperty

A Dynamic Entity always contains an item of your data - a book, person, blog-post or a piece of content. Since the object is dynamic, you can just use .IsFemale or whatever other property your item has. It is treated as a dynamic so you can just output it, or cast it to the expected type.

dynamic AnyProperty { get; }

Property Value

dynamic

Methods

Get(string)

Get a value of the entity. Usually you will prefer the quick access like @content.FirstName - which will give you the same things as content.Get("FirstName"). There are two cases to use this:

  • when you dynamically assemble the field name in your code, like when using App.Resources or similar use cases.
  • to access a field which has a conflicting name with this object, like Get("Parents")
dynamic Get(string name)

Parameters

name string

Returns

dynamic

An object which can be either a string, number, boolean or List<IDynamicEntity>, depending on the field type. Will return null if the field was not found.

Get(string, NoParamOrder, string, bool, bool?)

Get a property using the string name. Only needed in special situations, as most cases can use the object.name directly

dynamic Get(string name, NoParamOrder noParamOrder = default, string language = null, bool convertLinks = true, bool? debug = null)

Parameters

name string

the property name like Image - or path like Author.Name (new v15)

noParamOrder NoParamOrder

see Convention: Named Parameters

language string

Optional language code - like "de-ch" to prioritize that language

convertLinks bool

Optionally turn off if links like file:72 are looked up to a real link. Default is true.

debug bool?

Set true to see more details in Insights how the value was retrieved.

Returns

dynamic

a dynamically typed result, can be string, bool, etc.

Get<TValue>(string)

Get a value using the name - and cast it to the expected strong type. For example to get an int even though it's stored as decimal.

TValue Get<TValue>(string name)

Parameters

name string

the property name like Image - or path like Author.Name (new v15)

Returns

TValue

The typed value, or the default like null or 0 if casting isn't possible.

Type Parameters

TValue

The expected type, like string, int, etc.

Remarks

Added in v15

Get<TValue>(string, NoParamOrder, TValue)

Get a value using the name - and cast it to the expected strong type. For example to get an int even though it's stored as decimal.

Since the parameter fallback determines the type TValue you can just write this like `Content.Get("Title", fallback: "no title")

TValue Get<TValue>(string name, NoParamOrder noParamOrder = default, TValue fallback = default)

Parameters

name string

the property name like Image - or path like Author.Name (new v15)

noParamOrder NoParamOrder

see Convention: Named Parameters

fallback TValue

the fallback value to provide if not found

Returns

TValue

The typed value, or the default like null or 0 if casting isn't possible.

Type Parameters

TValue

The expected type, like string, int, etc. Note that you don't need to specify it, if you specify the fallback property.

Remarks

Added in v15