Sdl.Web.Tridion/Providers/ModelService/ModelService.cs
/// <summary>
/// Gets an Entity Model for a given Entity Identifier.
/// </summary>
/// <param name="id">The Entity Identifier. Must be in format {ComponentID}-{TemplateID}.</param>
/// <param name="localization">The context Localization.</param>
/// <returns>The Entity Model.</returns>
/// <exception cref="DxaItemNotFoundException">If no Entity Model exists for the given URL.</exception>
Gets an Entity Model for a given Entity Identifier.
Gets an Entity Model for a given Entity Identifier .
public EntityModel GetEntityModel(string id, ILocalization localization)
        {
            using (new Tracer(id, localization))
            {
                EntityModel result;
                if (CacheRegions.IsViewModelCachingEnabled)
                {
                    EntityModel cachedEntityModel = SiteConfiguration.CacheProvider.GetOrAdd(
                        $"{id}-{localization.Id}", 
                        CacheRegions.EntityModel,
                        () => LoadEntityModel(id, localization)
                        );
                    result = (EntityModel)cachedEntityModel.DeepCopy();
                }
                else
                {
                    result = LoadEntityModel(id, localization);
                }
                return result;
            }
        }
public EntityModel GetEntityModel ( string id , ILocalization localization ) { using ( new Tracer ( id , localization ) ) { EntityModel result ; if ( CacheRegions . IsViewModelCachingEnabled ) { EntityModel cachedEntityModel = SiteConfiguration . CacheProvider . GetOrAdd ( $" { id } - { localization . Id } " , CacheRegions . EntityModel , ( ) => LoadEntityModel ( id , localization ) ) ; result = ( EntityModel ) cachedEntityModel . DeepCopy ( ) ; } else { result = LoadEntityModel ( id , localization ) ; } return result ; } }
Gets an Entity Model for a given Entity Identifier.
Gets an Entity Model for a given Entity Identifier .
// key // Don't return the cached Entity Model itself, because we don't want dynamic logic to modify the cached state.
The Entity Model.
The Entity Model .
If no Entity Model exists for the given URL.
If no Entity Model exists for the given URL .
id
string
The Entity Identifier. Must be in format {ComponentID}-{TemplateID}.
The Entity Identifier . Must be in format { ComponentID } - { TemplateID } .
localization
ILocalization
The context Localization.
The context Localization .