Copied to clipboard

Flag this post as spam?

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


  • Damiaan 442 posts 1302 karma points MVP 6x c-trib
    Dec 23, 2013 @ 16:28
    Damiaan
    0

    uQuery does database hit

    I though that uQuery worked against the XML cache.

    But i noticed that this line of code does a query against the database:

    if (uQuery.GetUmbracoObjectType(nodeId) == uQuery.UmbracoObjectType.Media)
    

    This SQL statement was launched:

    SELECT nodeObjectType FROM umbracoNode WHERE id = 5366
    

    Because the UmbracoHelper replaces uquery (according to the documentation), I was searching for a way to replace this using the new API. Has anyone an idea how to do this?

  • Damiaan 442 posts 1302 karma points MVP 6x c-trib
    Dec 23, 2013 @ 16:54
    Damiaan
    100

    Found it!

     var umbHelper = new UmbracoHelper(UmbracoContext.Current);
     var mediaPickerContent = umbHelper.TypedMedia(nodeId);
     if (mediaPickerContent == null || mediaPickerContent.ItemType != PublishedItemType.Media)
     {
       // do stuff
     }
    

    If null is returned it was probably NOT a Media item. To be sure I added the "item type" check.

Please Sign in or register to post replies

Write your reply to:

Draft