1

We're using interfaces for our models with [SitecoreType(AutoMap=true)]. The templates we're using (for a refit, we didn't create them) have "Name" fields, but when I just declare string Name {get; set;} it's grabbing the Sitecore item name and not the Name field defined in the template. I have the template name field being declared with the SitecoreInfo property to a different "ItemName" field to prevent conflicts.

We've used the Name field before in other templates, thinking it was pulling from the template and not the item name, so I don't know if this is a change in the latest Glass Mapper or something we didn't previously notice.

For now, I'm having our developers use the SitecoreField("Name") attribute and call the field something like "NameField" - this is getting the correct field, so we have a workaround. But I was curious if this is something that changed, if it's been that way and I hadn't noticed, or if this is a bug and "Name" should map to a field template first, and only if there is no field with that appellation use the item's name.

1

Certain property names do trigger that - same as Id gets automapped to the ID of the Sitecore element. To get around that you would simply need to map the Name property normally using attribute / fluent configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.