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 289903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:56:57+00:00 2026-05-12T05:56:57+00:00

Lets look at the following structure first (I have tried to simplify it to

  • 0

Lets look at the following structure first (I have tried to simplify it to just show what kind of query I want)

class NameAddress
  {    
      public string Name { get; set; }
      public string Address { get; set; }
      public NameAddress(string sName, string sAddress) { Name = sName; Address = sAddress; }    
  }

  static void Main(string[] args)
  {
      Dictionary<int, Dictionary<string, NameAddress>> _dictionary = new Dictionary<int,Dictionary<string,NameAddress>>() 
          { 
            {/*int Key=*/1, /*Dictionary<str, NameAddress> value(1)=*/new Dictionary<string, NameAddress>() { {"First", new NameAddress("John Doe", "Mexico")}} },
            {/*int Key=*/2, /*Dictionary<str, NameAddress> value(2)=*/new Dictionary<string, NameAddress>() { {"Second", new NameAddress("Morris", "Washington")}, { "Third", new NameAddress("Keith", "New York")}} }
          };    
   }

I want to query the following data structure using a single linq query.
Let’s say I want to find the guy who lives in New York and HIS key as well. The integer keys (_dictionary Keys) are not that important but the string Key (in this case – “Third”) is the one that I want to find out.

Is it possible to find that the string Key and the particular NameAddress in a single linq query? If yes, what is that query?

  • 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-05-12T05:56:57+00:00Added an answer on May 12, 2026 at 5:56 am

    Note that this iterates over the dictionary (rather than using the index), but it works:

      var found = (from outer in _dictionary
                   from inner in outer.Value
                   where inner.Value.Address == "New York"
                   select new {
                       OuterKey = outer.Key,
                       InnerKey = inner.Key,
                       NameAddress = inner.Value
                   }).FirstOrDefault();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

lets say i have a tree of the following structure: <div>node level1 <div>node level2
Lets say i have the following scenario: public class A { public String createString(final
lets say i have the following XML <?xml version=1.0 encoding=utf-8?> <names> <name first=John last=Doe/>
I know two approaches to Exception handling, lets have a look at them. Contract
Lets say I have the following array: my_array = [1, 5, 8, 11, -6]
Lets say i have the following set of interfaces.... public interface IStart { void
I have the following models: # Group for Key/Value pairs class Group(models.Model): name =
I have the following problem in R: Lets assume the following data frame: a
Let's say I have this simple structure class FooDefinition { public FooDefinition Parent {
Lets say I have a table with the following rows/values: +--------+----------+ | ID |

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.