예제 #1
0
 /// <summary>
 /// Execute a broker query to populate a list of teasers
 /// </summary>
 /// <param name="list">The list definition</param>
 public override void PopulateDynamicList(ContentList<Teaser> list)
 {
     BrokerQuery query = new BrokerQuery
     {
         Start = list.Start,
         PublicationId = Int32.Parse(WebRequestContext.Localization.LocalizationId),
         PageSize = list.PageSize,
         SchemaId = MapSchema(list.ContentType.Key),
         Sort = list.Sort.Key
     };
     list.ItemListElements = query.ExecuteQuery();
     foreach (var item in list.ItemListElements)
     {
         item.Link.Url = ContentResolver.ResolveLink(item.Link.Url);
     }
     list.HasMore = query.HasMore;
 }
 /// <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>
 public virtual void PopulateDynamicList(DynamicList dynamicList, Localization localization)
 {
     using (new Tracer(dynamicList, localization))
     {
         Common.Models.Query query = dynamicList.GetQuery(localization);
         if (query == null || !(query is SimpleBrokerQuery))
         {
             throw new DxaException(string.Format("Unexpected result from {0}.GetQuery: {1}", dynamicList.GetType().Name, query));
         }
         BrokerQuery brokerQuery = new BrokerQuery((SimpleBrokerQuery) query);
         dynamicList.QueryResults = brokerQuery.ExecuteQuery(dynamicList.ResultType).ToList();
         dynamicList.HasMore = brokerQuery.HasMore;
     }
 }