Skip to main content
added 9 characters in body
Source Link
jammykam
  • 13.9k
  • 2
  • 29
  • 74

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:

Line 75:

[SitecoreField(<#= AsInterfaceName(template.Name) #>Constants.<#= GetPropertyName(field) #>FieldName <#= GetGlassFieldLoadLazily(field) #>)]

Line 119:

[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.

TDS Don't Lazily Load

Generate the code for your project and then property will now be added to the generated code.

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;
    bool.TryParse(loadLazy, out isLoadLazy);

    if (isLoadLazy)
        return ", Setting = SitecoreFieldSettings.DontLoadLazily";

    return string.Empty;
}

Next update the code generation to reference your method and pass through the field settings:

Line 75:

[SitecoreField(<#= AsInterfaceName(template.Name) #>Constants.<#= GetPropertyName(field) #>FieldName <#= GetGlassFieldLoadLazily(field) #>)]

Line 119:

[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.

TDS Don't Lazily Load

Generate the code for your project and then property will now be added to the generated code.

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 isDontLoadLazy;
    bool.TryParse(loadLazy, out isDontLoadLazy);

    if (isDontLoadLazy)
        return ", Setting = SitecoreFieldSettings.DontLoadLazily";

    return string.Empty;
}

Next update the code generation to reference your method and pass through the field settings:

Line 75:

[SitecoreField(<#= AsInterfaceName(template.Name) #>Constants.<#= GetPropertyName(field) #>FieldName <#= GetGlassFieldLoadLazily(field) #>)]

Line 119:

[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.

TDS Don't Lazily Load

Generate the code for your project and then property will now be added to the generated code.

Source Link
jammykam
  • 13.9k
  • 2
  • 29
  • 74

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;
    bool.TryParse(loadLazy, out isLoadLazy);

    if (isLoadLazy)
        return ", Setting = SitecoreFieldSettings.DontLoadLazily";

    return string.Empty;
}

Next update the code generation to reference your method and pass through the field settings:

Line 75:

[SitecoreField(<#= AsInterfaceName(template.Name) #>Constants.<#= GetPropertyName(field) #>FieldName <#= GetGlassFieldLoadLazily(field) #>)]

Line 119:

[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.

TDS Don't Lazily Load

Generate the code for your project and then property will now be added to the generated code.