Sdl.Web.Tridion/Providers/DefaultContentProvider.cs
/// <summary>
/// Populates a Dynamic List by executing the query it specifies.
/// </summary>
/// <param name="dynamicList">The Dynamic List which specifies the query and is to be populated.</param>
/// <param name="localization">The context Localization.</param>
Populates a Dynamic List by executing the query it specifies.
Populates a Dynamic List by executing the query it specifies .
public virtual void PopulateDynamicList(DynamicList dynamicList, ILocalization localization)
        {
            using (new Tracer(dynamicList, localization))
            {
                SimpleBrokerQuery simpleBrokerQuery = dynamicList.GetQuery(localization) as SimpleBrokerQuery;
                if (simpleBrokerQuery == null)
                {
                    throw new DxaException($"Unexpected result from {dynamicList.GetType().Name}.GetQuery: {dynamicList.GetQuery(localization)}");
                }
                Common.Interfaces.IQueryProvider brokerQuery = new BrokerQueryProvider();
                string[] componentUris = brokerQuery.ExecuteQuery(simpleBrokerQuery).ToArray();
                Log.Debug($"Broker Query returned {componentUris.Length} results. HasMore={brokerQuery.HasMore}");
                if (componentUris.Length > 0)
                {
                    Type resultType = dynamicList.ResultType;
                    ComponentMetaFactory componentMetaFactory = new ComponentMetaFactory(localization.GetCmUri());
                    dynamicList.QueryResults = componentUris
                        .Select(c => ModelBuilderPipeline.CreateEntityModel(CreateEntityModelData(componentMetaFactory.GetMeta(c)), resultType, localization))
                        .ToList();
                }
                dynamicList.HasMore = brokerQuery.HasMore;
            }
        }
public virtual void PopulateDynamicList ( DynamicList dynamicList , ILocalization localization ) { using ( new Tracer ( dynamicList , localization ) ) { SimpleBrokerQuery simpleBrokerQuery = dynamicList . GetQuery ( localization ) as SimpleBrokerQuery ; if ( simpleBrokerQuery == null ) { throw new DxaException ( $" Unexpected result from  { dynamicList . GetType ( ) . Name } .GetQuery:  { dynamicList . GetQuery ( localization ) } " ) ; } Common . Interfaces . IQueryProvider brokerQuery = new BrokerQueryProvider ( ) ; string [ ] componentUris = brokerQuery . ExecuteQuery ( simpleBrokerQuery ) . ToArray ( ) ; Log . Debug ( $" Broker Query returned  { componentUris . Length }  results. HasMore= { brokerQuery . HasMore } " ) ; if ( componentUris . Length > 0 ) { Type resultType = dynamicList . ResultType ; ComponentMetaFactory componentMetaFactory = new ComponentMetaFactory ( localization . GetCmUri ( ) ) ; dynamicList . QueryResults = componentUris . Select ( c => ModelBuilderPipeline . CreateEntityModel ( CreateEntityModelData ( componentMetaFactory . GetMeta ( c ) ) , resultType , localization ) ) . ToList ( ) ; } dynamicList . HasMore = brokerQuery . HasMore ; } }
Populates a Dynamic List by executing the query it specifies.
Populates a Dynamic List by executing the query it specifies .
dynamicList
DynamicList
The Dynamic List which specifies the query and is to be populated.
The Dynamic List which specifies the query and is to be populated .
localization
ILocalization
The context Localization.
The context Localization .