Copied to clipboard

Flag this post as spam?

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


  • How Do I Delete My Account? 68 posts 433 karma points
    Nov 30, 2015 @ 08:58
    How Do I Delete My Account?
    0

    Querying: Have dynamic number of parameters?

    Hello everybody,

    I would like to fetch X number of, lets say, news articles. However, I would like to skip certain, choosen, news articles by ID.

    For instance. I want to take 10 news articles that are not in the array with ID's of news articles to skip. How can I query this? The ID's may be an array length from 0 to X.

    I have trouble explaining this so please, tell me if I need to explain it further.

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Nov 30, 2015 @ 10:10
    Dan Diplo
    100

    Here's an example of how you could do it using a published content query. Assume "articles" is a query that brings back all your articles and existingIds is an array of Ids you don't want to include in filtered list.

    var articles = Model.Content.Children();
    
    var existingIds = new int[] { 1234, 1235, 1236, 1238, 1239 };
    
     var filteredArticles = articles.Where(p => !existingIds.Contains(p.Id)).Take(10);
    
  • How Do I Delete My Account? 68 posts 433 karma points
    Nov 30, 2015 @ 13:21
    How Do I Delete My Account?
    0

    You're the boss, thx :)

Please Sign in or register to post replies

Write your reply to:

Draft