Ektron Content Types and AutoMapper

If you are working with Ektron you are probably already aware of Ektron SmartForms and the ability to turn them into strongly typed Content Types. If you are not familiar and want to get up to speed I recommend taking a gander at Bill Cava’s webinar on the subject located here. This is a great step in making it a bit easier to do some CRUD operations on SmartForm content but depending on what your SmartForm looks like, you might get a weird looking Content Type class when just relying on the class creation from using the xsd.exe tool.

Taking the transformation a step farther and turning the Content Type class into a true Domain Object can make your code a bit cleaner and further separate your business layer from your data layer which is always nice. Jimmy Bogard has a nice AutoMapper project located over at CodePlex that you can leverage to move between your domain objects and your SmartForm content types.
Automapper does a nice job of figuring out which field should be mapped to which field and it has the flexibility for you to take control of the mapping at a field or type level. If you have a Rich Text field in your SmartForm you will probably want to do something similar to the sample code below which introduces a custom resolver that makes it easier to map from a string field on the domain object to the corresponding rich text field on the SmartForm.

Automapper
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s