U4-1178 - IPropertyEditorValueConverter should be used when accessing strongly typed properties using GetPropertyValue

Created by Shannon Deminick 12 Nov 2012, 03:59:14 Updated by Sebastiaan Janssen 31 Jan 2013, 16:05:57

Relates to: U4-1405

Currently IPropertyEditorValueConverter is only used in dynamic property access, it should also be used in strongly typed property access. However, this is only possible with the GetPropertyValue extension methods and overloads, it is not possible with the GetProperty(alias).Value implementation because this is up to the implementation of IPublishedContent and we cannot guarantee this will happen.


Shannon Deminick 12 Nov 2012, 05:49:10

I have listed this as a breaking change because:

  • This requires that the overloads to the GetPropertyValue methods of the PublishedContentExtenions class return an 'object' not a 'string'. This is required in order to get the IPropertyEditorValueConverters to work because they can return any object. If we keep the 'string' returned then there is no point in the value converters as it will always be string. The only other option is to create new extension methods which contain the value conversion but this seems silly and redundant. For the most part, people wont even recognize this change since in their views any 'object' gets rendered to it's string equivalent. The only people who might see breaking changes is when doing things like Linq statements. For example, this used to work:

var result = doc.Ancestors().OrderBy(x => x.Level) .Single() .Descendants() .FirstOrDefault(x => x.GetPropertyValue("selectedNodes", "").Split(',').Contains("1173"));

but now that won't compile because GetPropertyValue returns 'object' not string, so you'll have to either cast it to a string or use the strongly typed method:

var result = doc.Ancestors().OrderBy(x => x.Level) .Single() .Descendants() .FirstOrDefault(x => x.GetPropertyValue("selectedNodes", "").Split(',').Contains("1173"));

fabrice loudet 26 Nov 2012, 07:34:27

Hello, In my company, we are heavily using GetPropertyValue (expecting string as return) to access all properties. If you change it to return an object it would be horrible for us... Thanks to not change it ;)

Jeroen Breuer 28 Nov 2012, 09:19:39

Didn't know this was already implemented in 4.11. It works great! Here is an example which can be used with the [DAMP Property Editor Value Converter|http://our.umbraco.org/projects/backoffice-extensions/damp-razor-model] package:

var brandboxImages = brandboxItem.GetPropertyValue<DAMP.PropertyEditorValueConverter.Model>("brandboxImageDamp");

@foreach(var media in brandboxImages) { @media.Alt }

Priority: Normal

Type: Feature (planned)

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category: Architecture

Backwards Compatible: False

Fix Submitted:

Affected versions: 4.10.0

Due in version: 4.11.0


Story Points: