Sdl.Web.Tridion/Providers/GraphQLContentProvider.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)}");
                }
                var cursors = CursorIndexer.GetCursorIndexer(dynamicList.Id);
                int start = simpleBrokerQuery.Start;
                simpleBrokerQuery.Cursor = cursors[start];
                simpleBrokerQuery.Start = cursors.StartIndex;
                dynamicList.Start = cursors.StartIndex;
                var brokerQuery = new GraphQLQueryProvider();
                var components = brokerQuery.ExecuteQueryItems(simpleBrokerQuery).ToList();
                Log.Debug($"Broker Query returned {components.Count} results. HasMore={brokerQuery.HasMore}");
                if (components.Count > 0)
                {
                    Type resultType = dynamicList.ResultType;
                    dynamicList.QueryResults = components
                        .Select(
                            c =>
                                ModelBuilderPipeline.CreateEntityModel(
                                    CreateEntityModelData((Component) c), resultType,
                                    localization))
                        .ToList();
                }
                dynamicList.HasMore = brokerQuery.HasMore;
                if (brokerQuery.HasMore)
                {
                    cursors[simpleBrokerQuery.Start + simpleBrokerQuery.PageSize] = brokerQuery.Cursor;
                }
            }
        }
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 ) } " ) ; } var cursors = CursorIndexer . GetCursorIndexer ( dynamicList . Id ) ; int start = simpleBrokerQuery . Start ; simpleBrokerQuery . Cursor = cursors [ start ] ; simpleBrokerQuery . Start = cursors . StartIndex ; dynamicList . Start = cursors . StartIndex ; var brokerQuery = new GraphQLQueryProvider ( ) ; var components = brokerQuery . ExecuteQueryItems ( simpleBrokerQuery ) . ToList ( ) ; Log . Debug ( $" Broker Query returned  { components . Count }  results. HasMore= { brokerQuery . HasMore } " ) ; if ( components . Count > 0 ) { Type resultType = dynamicList . ResultType ; dynamicList . QueryResults = components . Select ( c => ModelBuilderPipeline . CreateEntityModel ( CreateEntityModelData ( ( Component ) c ) , resultType , localization ) ) . ToList ( ) ; } dynamicList . HasMore = brokerQuery . HasMore ; if ( brokerQuery . HasMore ) { cursors [ simpleBrokerQuery . Start + simpleBrokerQuery . PageSize ] = brokerQuery . Cursor ; } } }
Populates a Dynamic List by executing the query it specifies.
Populates a Dynamic List by executing the query it specifies .
// get our cursor indexer for this list // given our start index into the paged list we need to translate that to a cursor // the cursor retrieved may of came from a different start index so we update start // update cursor
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 .