0

I have a object that was created using GlassMapper without doing a verbose property-by-property assignment?

information.Fields["field1"].Value = obj.Value
...

I was using this as a reference and it is helpful, but I want to use GlassMapper to save the items back. I tried using the following code block to use my GlassMapper object but I reach an exception that I explain below:

            Debug.Assert(informationItem != null, "informationItem != null");
            informationItem.Editing.BeginEdit();
            informationItem.GlassRead(model); //Could not find item to save value AbstractPropertyConfiguration Property: Position
            informationItem.Editing.EndEdit();

In my information model I declare CandidatePosition as such :

public virtual CandidatePosition Position { get; set; }

and the CandidatePosition is defined as such:

[SitecoreType]
public class CandidatePosition : BaseItem
{
    [SitecoreField]
    public virtual string Title { get; set; }
}

So the Title field should map to the Title field in the Sitecore item, but I think it is having trouble mapping it? I can confirm that the underlying object is not null and the Title field does have a value. Is there some attribute I'm missing that I need to apply or maybe I'm not following some convention?

I could go manual and just do it property by property but I feel it might not be necessary.

uioporqwerty
  • 317
  • 5
  • 22
  • The Glass website has a tutorial on how to save items: http://glass.lu/Mapper/Sc/Tutorials/Tutorial11 – Richard Seal Feb 23 '16 at 19:30
  • Seems like you need `informationItem.GlassRead(model.Position);` since Position is the item you are trying to save back. – jammykam Feb 23 '16 at 20:40

0 Answers0