filtering by Image in item list?

Posted by Josh Arquelada on January 20, 2016

Hi,

I am trying to get a list of BlogPost items filtering by a SmallImage attribute. SmallImage is of type Image but it not returning the expected number of results for each query.

var posts = new AgilityContentRepository<BlogPost>("BlogPosts").Items("SmallImage is not null");
var postNoImages = new AgilityContentRepository<BlogPost>("BlogPosts").Items("SmallImage is null");

It returns the correct total sum but incorrects amounts for either.

is there something I am doing wrong or is this possible?

   0 people like this question
15 30 50   per page
   
  
 
 
   
Submit
Currently, that would be our recommended way of doing it. You could also cache the entire list in memory after you've filtered it in linq.

Regards,
James
Posted By: James Vidler

Hi,

That is what I currently have but I was thinking that there maybe a more optimal way to do it.

Thanks,

Josh

Posted By: Josh Arquelada

Hi Josh,

Performing null checks on Image properties within the dataview row filter may provide unexpected results as we see here. It may be easier to perform a linq query on that like .Items().Where(b => b.SmallImage != null).ToList(); 

Regards,
James
Posted By: James Vidler

I tried and its returning the small result as "SmallImage is not null"

Posted By: Josh Arquelada

Hi Josh,

I believe you should be able to use the ISNULL function like:"Isnull(SmallImage,'') <> '' "



Regards, James
Posted By: James Vidler

Previous Next

LOGIN

Log in with your Agility username and password or
register for the site




Log In

REGISTER












Register

FORGOT PASSWORD