5

I am using Glass library as ORM for Sitecore. I have a field Images which contains the list of images. Since I want to access this from my .NET code, I have written a partial class which has the field images like:

[SitecoreField]
public virtual IEnumerable<Glass.Sitecore.Mapper.FieldTypes.Image> Images { get; set;}

But while loading this I am getting error.

The method or operation is not implemented.

Where as I am able to access the single image through Glass, without writing any additional code.

Can anyone please suggest something to fix this?

Marek Musielak
  • 26,832
  • 8
  • 72
  • 80
PM.
  • 1,735
  • 1
  • 30
  • 38
  • What is the type of your 'Images' field in your Sitecore template? I'm guessing treelist, or multilist. I don't know anything about the Glass library, but I'm guessing that the problem lies with the fact that it expects to map an image field in sitecore to it's own image class. Remember that sitecore stores multilist/treelist fields as a pipe-separated list of GUIDs, whereas images are stored quite differently - select View->Raw Values to see how it stores image fields. – Matthew Dresser Jan 04 '13 at 20:54
  • Thanks @mdresser for your help. But this was problem with the Glass library mapping. For which work around is as below. – PM. Jan 28 '13 at 06:28

1 Answers1

8

Our architect has solved this issue with the help of creator of Glass library. And the solution is like this..

    [SitecoreField]
    public virtual IEnumerable<MediaImage> Images { get; set;}

And Media Image is class like:

     [SitecoreClass]
public class MediaImage
{
    [SitecoreField("Attachment")]
    public virtual Stream Image { get; set; }

    [SitecoreInfo(SitecoreInfoType.MediaUrl)]
    public virtual string Url { get; set; }

    [SitecoreField("Alt")]
    public virtual string Alt { get; set; }
}

This has solved the issue and I am getting the list of images now.

PM.
  • 1,735
  • 1
  • 30
  • 38