Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9082093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:28:27+00:00 2026-06-16T20:28:27+00:00

I believe i’m missing something simple here, but i just can’t figure it out.

  • 0

I believe i’m missing something simple here, but i just can’t figure it out. Any kind of help would be much appreciated.

The problem:
The results that end up in the resultsWithMedia array only contain results that were matched against the first item in mediaTypesList. I’ve tried using Exists(), Find() and Contains(), but with no luck. I get the same kind of behavior each time.

For example: if mediaTypesList contains {"video", "link", "photo"} values, the resultsWithMedia will only hold results that are of type video.

What i’m trying to achieve is to have resultsWithMedia hold the values who’s type matches any of the values in mediaTypesList.

The code:

 public void GetPostsWithMedia(string from, string before, string mediaTypes)
    {
        // ... some variable declarations

        List<string> mediaTypesList = new List<string>();

        if (!string.IsNullOrEmpty(mediaTypes))
        {
            var list = mediaTypes.Split(',');

            foreach (var type in list)
            {
                mediaTypesList.Add(type);
            }
        }

        // ... some more code 

        // Note: r.Data is a Dictionary that contains strings as it's values
        var resultsWithMedia = (from r in response.Results
                                where r.Data.ContainsKey("Type") && mediaTypesList.Exists(t => t == r.Data["Type"]) 
                                select new 
                                {
                                    // ... different variables
                                }).ToArray();

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:28:28+00:00Added an answer on June 16, 2026 at 8:28 pm

    You can get results with media in one query:

    var query = from r in response.Results.Where(x => x.Data.ContainsKey("Type"))
                join m in mediaTypes.Split(',')
                     on r.Data["Type"] equals m
                select new {
                    ...
                };
    

    If you need case-insensitive comparison for media type and data, apply ToLower(): on r.Data["Type"].ToLower() equals m.ToLower(). Also consider to apply m.Trim() if there is empty space in media type name after splitting string (as Euphoric suggested).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe this is a fairly simple question but it is something I am
I believe it has something to do with draw order, but I've just given
I believe this is a simple fix but so far I can't find it.
I believe the answer may be quite simple but i cant find the answer
I believe the title is self-explanatory, but here's an example to illustrate what I'm
I believe my question is relatively basic but I still haven't found something that
I believe a Group By would solve the following, but maybe it's Select Distinct.
I believe this is a simple question. How can I remove the ".mp3" extension
I believe I have read this somewhere, but I can't find it nomatter how
I believe there is something wrong with my INSERT statement here. When I run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.