You can update the GlassV3Item.tt file and make use of the Custom Data
property in TDS to set whether a field should not be lazy loaded.
Let's add some comments to keep this clean. Add this near the top of the file with the rest of the setting comments (Line 38 on clean tt file)
/*
dontloadlazy=true
Sets the field setting to DontLoadLazily
*/
Add a new method to the end of the file which will check whether the field has the above property set on it in TDS (Line 240 on a clean file):
public static string GetGlassFieldLoadLazily(SitecoreField field)
{
string loadLazy = GetCustomProperty(field.Data, "dontloadlazy");
bool isLoadLazy;isDontLoadLazy;
bool.TryParse(loadLazy, out isLoadLazyisDontLoadLazy);
if (isLoadLazyisDontLoadLazy)
return ", Setting = SitecoreFieldSettings.DontLoadLazily";
return string.Empty;
}
Next update the code generation to reference your method and pass through the field settings:
[SitecoreField(<#= AsInterfaceName(template.Name) #>Constants.<#= GetPropertyName(field) #>FieldName <#= GetGlassFieldLoadLazily(field) #>)]
[SitecoreField(<#= AsInterfaceName(template.Name) #>Constants.<#= GetPropertyName(field) #>FieldName <#= GetGlassFieldLoadLazily(field) #>)]
For every field which you wish the setting to apply to, update the properties for that field in TDS and set dontloadlazy=true in Custom Data
.
Generate the code for your project and then property will now be added to the generated code.