12

I have looked through the documentation and tutorials on the Glass Mapper site, but I can't find a list of the different attributes that are available and what they do.

14
  • SitecoreChildrenAttribute - Maps children of the current item. Expects an IEnumerable<T>
  • SitecoreFieldAttribute - Maps from a field on the current item
  • SitecoreFieldFieldValueAttribute - Used to populate default values of a field's field
  • SitecoreIdAttribute - Maps the Sitecore item ID. Expects the property to be a Sitecore.Data.ID or Guid
  • SitecoreIgnoreAttribute - Ignores the property and doesn't map anything.
  • SitecoreInfoAttribute - Maps from various item properies according to the provided SitecoreInfoType parameter which can have the following values:
    • ContentPath - The item's content path. The property type must be System.String
    • DisplayName - The item's display name. The property type must be System.String
    • FullPath - The item's full path. The property type must be System.String
    • Key - The item's key. The property type must be System.String
    • ItemUri - The item's ItemUri . The property type must be Sitecore.Data.ItemUri
    • MediaUrl - The item's media URL. The property type must be System.String
    • Path - The item's path. The property type must be System.String
    • TemplateId - The item's template Id. The property type must be System.Guid
    • TemplateName - The item's template name. The property type must be System.String
    • Url - The item's URL. The property type must be System.String
    • Version - The item's version. The property type must be System.Int32
    • Name - The item's Name. The property type must be System.String
    • Language - The items language. The property type must be Sitecore.Globalization.Language
    • BaseTemplateIds - Gets the Base Template IDs - does not return the template is. The property type must be IEnumerable<Guid>
  • SitecoreItemAttribute - Maps the context item
  • SitecoreLinkedAttribute - Maps references using the LinkDatabase. Expects an IEnumerable<T>
  • SitecoreNodeAttribute - Maps the item specified by the provided Id or Path parameter
  • SitecoreParentAttribute - Maps the parent of the current item
  • SitecoreQueryAttribute - Maps the results of a Sitecore Query. Expects an IEnumerable<T>. See the official tutorial for details.
  • SitecoreSelfAttribute - Maps the current model item. Typically used to map a template section to a different model for easier reuse.

Most of this info was found by reading the source code and comments on Github

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.