Copied to clipboard

Flag this post as spam?

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


  • Adrian 9 posts 109 karma points
    Jul 07, 2021 @ 09:45
    Adrian
    0

    Hi,

    I'm trying to modify a query that searches for all media items of a single document type under a folder to return all media items that are one of two document types. Pretty sure this is very simple and I'm just missing something, but could anyone help?

    Existing query:

    fileList = Umbraco.TypedMediaAtRoot().DescendantsOrSelf("File").Where(x => x.Path.Contains(Model.DocumentFolder.Id.ToString()))
    

    I assumed I could do one of the following but neither are correct:

    <snip> .DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "File" || x.DocumentTypeAlias == "OtherDocTypeName") <snip>
    

    or

    <snip> .DescendantsOrSelf("some or query in here") <snip>
    
  • Erik Eelman 79 posts 319 karma points
    Jul 07, 2021 @ 11:59
    Erik Eelman
    0

    Hi Adrian,

    You could try this:

    var fileList = Umbraco.TypedMedia(Model.DocumentFolder.Id).Descendants("File").ToList()
    
  • Adrian 9 posts 109 karma points
    Jul 07, 2021 @ 12:45
    Adrian
    0

    Hi

    That wouldn't solve the problem, I'd still need an or clause inside Descendants()

  • Erik Eelman 79 posts 319 karma points
    Jul 07, 2021 @ 13:41
    Erik Eelman
    100

    Hi,

    This should work:

    Umbraco.TypedMedia(Model.DocumentFolder.Id).Descendants().Where(x => x.DocumentTypeAlias == "File" || x.DocumentTypeAlias == "OtherType").ToList();
    
  • Adrian 9 posts 109 karma points
    Jul 07, 2021 @ 17:11
    Adrian
    0

    That's worked perfectly, thank you for your help.

Please Sign in or register to post replies

Write your reply to:

Draft