AsList(...) - Magic Lists
In razor you prefer a simple
@Something.Property syntax. If you only have one item, you'll use AsDynamic(...). When you need a list to go through, you use
⚡ The official API docs.
Discover More in the Razor Tutorials
We have an rich series of Razor tutorials. You should really check them out 👍.
How it works
AsList has various signatures accepting a variety of input values. It then returns an
IEnumerable<dynamic> object which is a
List of IDynamicEntity objects. These are the things AsList can process:
IEnumerable<IEntity>- will return a List/IEnumerable of IDynamicEntity
IEnumerable<IDynamicEntity>- will return the same thing again
this option exists just so you don't have to pre-check what you pass in, making it easier to code for you
- a IDataStream - will return a List/IEnumerable of IDynamicEntity
- a IDataSource - will return a List/IEnumerable of IDynamicEntity of the
To use the latest features of 2sxc 12+, make sure your razor file begins with the line
Otherwise your Razor templates is based on the default, older component code.
- Introduced in 2sxc 10.20