Tweeted twitter.com/#!/StackTridion/status/312665961905926145
2 edited tags
| link
1
source | link

Accessing Embedded Schema fields via list of Component Links

I have a razor component template which is looping through a list of component links trying to read out fields that come from an embedded schema. The Embedded Schema contains fields like Title, Body, Summary etc. I've read the Razor Mediator documentation which also indicates this is the correct method to adopt.

My code looks like this:

@foreach(dynamic item in List)
{
  @item.EmbeddedSchemaName.EmbeddedSchemaFieldName 
}

When I try to preview the page I get the typical razor error indicating the field doesn't exist:

Cannot perform runtime binding on a null reference

Can anyone see a problem here?