Table of Contents

Dynamic Code API

Every C# file in 2sxc is Dynamic Code as it's compiled on-the-fly and has a lot of helpers to work with Dynamic Data.

you are here (click to zoom) - discover the stack

The following APIs are available on all 2sxc Dynamic Code. You can use this in:

  1. Razor
  2. WebAPI Controllers
  3. Helper Code files
Discover More in the Razor Tutorials

We have an rich series of Razor tutorials. You should really check them out 👍.


Instance Data in Dynamic Code

Note

Instance specific data belongs to the module-instance on the page, either because it was added manually as Content or because the View of the module-instance uses a Query.

Best read about App vs. Instance Data and Where Data Comes From

  1. Content
    The primary and often the only content-items for this template.
  2. Content.Presentation
    Can contain additional presentation settings for this content, like how to format it.
  3. Data
    One or more Streams (lists) of zero-or-more content items
  4. Header
    The header data if the template expects to be a list and also needs a title or intro.
  5. Header.Presentation
    Can contain additional presentation settings for the header, like how to format it.

App and App-Data Objects

  1. App
    The current App with Settings, Resources, Path information and more.
  2. App.Data
    All the data of the current app for immediate use, fully cached in memory of the web server.
  3. App.Query
    Queries which were created using VisualQuery and can be run to access prepared data.

General Objects

  1. CmsContext
    Information about the system, page, module etc.
  2. Dnn
    The common Dnn object providing page, module, user information
  3. Edit
    Helper providing you with various edit-functionality like Toolbar(...)
  4. Link
    Helper to generate links, according to the Dnn-environment configuration

Conversion Commands

  1. AsAdam(...)
    Gives you the ADAM parts (files, images, folders) of a field.
  2. AsDynamic(entity) - takes just about anything (an iEntity, a list of iEntities, a dynamic, ...) and casts it to a DynamicEntity
  3. AsDynamic(jsonString)
  4. AsList(listOfEntities)
  5. AsEntity(...) - takes just about anything (iEntity, DynamicEntity, list of that) and casts it to an iEntity

Helper Commands provided by 2sxc

Important Notes

Important

Your code must inherit the correct base class to get this API. You'll find the correct base classes in the documentations for Razor and Web API.