Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Magnus 1 post 21 karma points
    Jan 10, 2013 @ 10:09
    Magnus
    0

    Razor Examine problem...

    Istead of using "@foreach(var item in Model.Children)" wich gets really slow with a lot of items I'm trying to lookup items with "Examine". I works pretty fast but I have some problems:

    1. In the Criteria part, first I must create a dummy field wich dosen't exist, just to make the following fieds work. What am I doing wrong?

    2. In the Criteria part, I can only use some of the fields not all even if I know there exist and contains data. Why?

    3. when using "result.Fields["X"]", I can only use some of the fields not all even if I know there exist and contains data. Why?

    4. I have same problem with "@Model.NodeById(@tempID).X" - works fine for some fields but will not display
    anything for some fields (wich I know exist and contains data). Why?

     

    The code:

     

    var criteria ExamineManager.Instance.CreateSearchCriteria(IndexTypes.Content);
                         var query criteria
                                  .Field("xzy""")
                                  .And()
                                  .Field("hotelCode",@Page.hotelCode)
                                  .And()
                                  .Field("iATACode1",@subitem.iATACode1)
                                  .And()
                                  .Field("iATACode2",@subitem.iATACode2)
                                 
                                  .Compile();
                                 
                      
                          var Searcher ExamineManager.Instance.DefaultSearchProvider.Name;
                          var searchResults ExamineManager.Instance.SearchProviderCollection[Searcher].Search(query);
                         
                         

                          foreach (var result in searchResults)
                          {
                              
                                   var tempHotelName ""
                                   var tempHotelCode "";
                                   var tempSiteURL "";
                                   var tempIATA_1 "";
                                   var tempIATA_2 "";
                                   var tempHotelStayAway "";
                                   var tempFromDate "";
                                   var tempID @result.Id.ToString();
                                   
                                            
                                           if (result.Fields.ContainsKey("hotelName"){
                                                    tempHotelName result.Fields["hotelName"];
                                            }
                                           if (result.Fields.ContainsKey("hotelCode"){
                                                    tempHotelCode result.Fields["hotelCode"];
                                            }
                                           if (result.Fields.ContainsKey("siteURL"){
                                                    tempSiteURL result.Fields["siteURL"];
                                            }
                                           if (result.Fields.ContainsKey("iATA_1"){
                                                    tempIATA_1 result.Fields["iATA_1"];
                                            }
                                           if (result.Fields.ContainsKey("iATA_2"){
                                                    tempIATA_2 result.Fields["iATA_2"];
                                            }
                                           if (result.Fields.ContainsKey("hotelStayAway"){
                                                    tempHotelStayAway result.Fields["hotelStayAway"];
                                            }
                                           if (result.Fields.ContainsKey("hotelFromDate"){
                                                    tempFromDate result.Fields["hotelFromDate"];
                                            }
                                     
                               
                                              <Div style="float:left; border:1px solid green; width:100%; margin:10px;">
                                                 Code:  @Model.NodeById(@tempID).hotelCode |
                                                 Namn:  @Model.NodeById(@tempID).Name |
                                                 ID:  @Model.NodeById(@tempID).Id (@tempID|
                                                 Site:  @Model.NodeById(@tempID).siteURL |
                                                 FromDate:  @Model.NodeById(@tempID).hotelFromDate |
                                              </div>
                                     
                                              
                      
                          }
                                     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies