14. January 2014 00:01
/
Administrator
/
/
Comments (0)
- Associate mapped class need load the assembly which contains the mapped class.
public static class GlassMapperScCustom
{
...
public static IConfigurationLoader[] GlassLoaders(){
/* USE THIS AREA TO ADD FLUENT CONFIGURATION LOADERS
*
* If you are using Attribute Configuration or automapping/on-demand mapping you don't need to do anything!
*
*/
return new IConfigurationLoader[] { new AttributeConfigurationLoader("Choice.Domain.Sitecore") };
}
...
}
- Auto mapping process the string value, for example, stripping off hyphen with space. To fix this, always specify FieldType:
[SitecoreType(TemplateId = "{A82DA878-D247-4124-927F-A01C28CD6CAB}", AutoMap = true)]
public class ProductField
{
[SitecoreField(FieldName = "Key", FieldType = SitecoreFieldType.SingleLineText)]
public virtual string Key { get; set; }
}
f1b0690e-c4f3-4942-86b2-3fcc12670f04|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
9. January 2014 11:47
/
Administrator
/
/
Comments (0)
The dream tool to map between model class to Sitecore item. Check it out:
http://glass.lu/
Step 1, Sitecore Item:
Step 2. Model class
public class HomePage
{
public virtual string Title { get; set; }
public virtual string MainBody { get; set; }
}
Step 3. Sublayout Code-behind:
public partial class HomePageSublayout : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
var context = new SitecoreContext();
Model = context.GetCurrentItem<HomePage>();
}
public HomePage Model { get; set; }
}
fa50b716-f837-47ad-a60e-0d09a82131b3|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04