Copied to clipboard

Flag this post as spam?

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


  • Sameer 6 posts 88 karma points
    Aug 23, 2016 @ 07:26
    Sameer
    0

    Query where clause is not producing desired results

    Hi there, I am working in a partial view and I need to get video lectures in a partial view. Following is query that is working fine

    @using YouTube
    @using YouTube.Models   
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        var homePage = CurrentPage.AncestorsOrSelf(1).First();  
        var lectureVideos = homePage.Descendants("videoLecture").Where("Visible").OrderBy("publishDate desc, createDate desc");     
    }
    

    But I need to filter the videos based on their description property named as "lectureDescription", a rich text editor. I want to exclude those videos having no description. I have run the following query but it's not working and its giving no result at all.

    @using YouTube
    @using YouTube.Models   
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        var homePage = CurrentPage.AncestorsOrSelf(1).First();  
        var lectureVideos = homePage.Descendants("videoLecture").Where("Visible").Where("lectureDescription != @0 && lectureDescription != @1",null,String.Empty).OrderBy("publishDate desc, createDate desc");
    }
    

    Can someone point out and guide me into right direction, I will be thankful.

  • Sameer 6 posts 88 karma points
    Aug 24, 2016 @ 06:01
    Sameer
    0

    Anyone? Kindly give me any suggestion.

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 24, 2016 @ 06:46
    David Brendel
    0

    Hi Sameer,

    I'm not working with the dynamic syntax but maybe you can cross check what happens when you use the strongly typed one.

    Something like

    homePage.Descendants("videoLecture").Where(x => x.IsVisible()).Where(x => !String.IsNullOrEmpty(x.GetPropertyValue<string>("lectureDescription")));
    

    Maybe that helps to figure out what the problem is.

    Regards David

Please Sign in or register to post replies

Write your reply to:

Draft