Copied to clipboard

Flag this post as spam?

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


  • Sigurd Aabøe-Sagen 12 posts 122 karma points
    Apr 06, 2018 @ 08:28
    Sigurd Aabøe-Sagen
    0

    Combined taggroups in a List<IpublishedContent> gives me zero results when excluding with where

    Hi

    I am trying to combine to sets of taggroups and the best way i have found is to combine then into a List. That works great and all my results is showing. However in my result i want to exclude items that dont have the same tags.

    Example: I have a tag for thematics "Onboarding" and a tag for medium: "Webinar". But if i dont exclude and puts in f.eks "Ebook" in the medium tag, i will get results that is also not in the thematics "Onboarding". I have tried to do a where clausul in the combined result but i dont get ANYthing whit this query. It seems like the GetPropertyValue just returns System.String[].. Is this a bug or is my code just messed up.. Any other suggestions would be great aswell.

        string m = Request.QueryString["m"]; //medium
        string t = Request.QueryString["t"]; //tema
    
        IEnumerable<IPublishedContent> tema = Umbraco.TagQuery.GetContentByTag(t, "tema").OrderBy("CreateDate desc");
        IEnumerable<IPublishedContent> types = Umbraco.TagQuery.GetContentByTag(m, "contenttype").OrderBy("CreateDate desc");
    
        List<IPublishedContent> combinedResults = new List<IPublishedContent>();
        combinedResults.AddRange(tema);
        combinedResults.AddRange(types);
    
        //Response.Write(combinedResults.Count());
    
        contentitems = combinedResults.Where(x => x.GetPropertyValue<string[]>("contentTypeTags").Contains(m) && x.GetPropertyValue<string[]>("temaTags").Contains(t)).GroupBy(x => x.Id).Select(x => x.First());
    
Please Sign in or register to post replies

Write your reply to:

Draft