Copied to clipboard

Flag this post as spam?

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


  • Damiaan 438 posts 1290 karma points MVP 3x 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 438 posts 1290 karma points MVP 3x 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.

  • 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