Closed ribsdigital closed 2 years ago
@ribsdigital Konstrukt doesn't have anything to do with Models Builder and nor does it run Value Converters. Konstrukt simply uses property editors as a mechanism for editing a POCO model. What is persisted in the database is what you get access to on your POCO model. If you need to change that to another format, you need to use Value Mappers https://docs.getkonstrukt.net/api/value-mappers
Hey @mattbrailsford I think you might have misunderstood the issue. In your documentation in the Extras section, you have a page about Entity Pickers which can be put on doctypes to pick entities from the Database and at the end of that page you have section: https://docs.getkonstrukt.net/extras/property-editors/entity-picker#getting-the-value-of-an-entity-picker
The entity picker property editor comes with a built in value converter meaning that whenever you retrieve the property value from Umbraco it will return the actual selected entities.
// Example
foreach(var p in Model.Content.People.Cast<Person>()){
...
}
Note: Due to the fact that the property editor can link to any entity type, the returned value type from the value converter will be IEnumerable<object>
and so will require the entities to be cast to the desired concrete type.
The issue that @ribsdigital is facing is that we don't get an IEnumerable back. We only get a Object.
It appears that maybe the builtin valueconverter you mention is not working / is not registered / doesnt exist, and therefore when when we try to retreive the values we get Object. That Object only contains a comma delimited list of Database Entity IDs.
The other thing is that the example is in an Umbraco 8 format? Model.Content
So we are wondering if this this documentation section is a hangover from Fluidity? And if so, is it expected that the developer needs to write their own valueConverter now? Or should there be one?
@pgregorynz doh! My bad, you're right, I totally misunderstood the question.
You are also right that the value converter appeared to be missing. I must have forgotten about it in the port over.
I've gone an implemented it now on a 1.0.3 unstable build if you want to try it. The nice thing in v9, I can even tell models builder the expected type so it will already be cast to the right entity type (I've updated the docs accordingly).
Give it a try and let me know if it resolves your issue.
hi @mattbrailsford we're having a bit of trouble installing the build, visual studio can't seem to find it on the nuget feed...
was there any hypens ect in the package name?
Have you enabled the nuget option to allow installing pre-releases?
hi @mattbrailsford weird... it wasn't happy via the package manager console but it's fine via 'manage packages' 😕
but yup, all good - the converter kicks in and we now get an IEnumerable<People>
:
happy days 👍
Describe the bug the 'entity picker' doesn't appear to be using the value converter as the type in the generated models builder class is
object
notIEnumerable<object>
as described in the documentation https://docs.getkonstrukt.net/extras/property-editors/entity-picker#getting-the-value-of-an-entity-pickerSteps To Reproduce Steps to reproduce the behavior:
Konstrukt Entity Picker
and configure it to talk to a entityExpected behavior an
IEnumerable<object>
type in the generated modelEnvironment (please complete the following information):
Additional context would it also be possible to give the code path to the property value converter as we need to call the
ConvertIntermediateToObject
method in another area of the backend code?