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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:26:42+00:00 2026-06-11T20:26:42+00:00

I query a hierarchical data source like this: repository.LookupValue(IEnumerable<string> ascendants) where ascendants is a

  • 0

I query a hierarchical data source like this:

repository.LookupValue(IEnumerable<string> ascendants)

where ascendants is a list of strings representing the path to the node being looked up.

I would like to cache results from these lookups. I had envisioned using a Dictionary<IEnumerable<string>, long>, but it seems when using an IEnumerable<string> as a dictionary key, reference equality is used, which is no good to me.

I could of course define my own type wrapping IEnumerable<string> and override it’s .Equals method, but that seems extreme.

Am I missing a simpler solution to the caching problem? Can anyone advise?

  • 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-11T20:26:44+00:00Added an answer on June 11, 2026 at 8:26 pm

    Use a Dictionary but use the constructor that takes an IEqualityComparer. Write a custom implementation of this to compare your collection of ascendants and pass it in.

    Here’s an example (comparing arrays in this case) that uses built in StructuralComparisons.

        public class StringArrayComparer : IEqualityComparer<string[]>
        {
            public bool Equals(string[] x, string[] y)
            {
                return StructuralComparisons.StructuralEqualityComparer.Equals(x, y);
            }
    
            public int GetHashCode(string[] obj)
            {
                return StructuralComparisons.StructuralEqualityComparer.GetHashCode(obj);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of hierarchical data like this: var list = new List<Data>(){some
How would one write a LINQ query which takes a hierarchical source data and
I have a table containing hierarchical data. There are currently ~8 levels in this
I'm using Connect By query to show hierarchical groups on a group, on this
I have a hierarchical class structure like this: Category -> Template -> Instance A
I want to fetch Hierarchical/Tree data something like below from a Table which has
I have a problem in a hierarchical query. I have a self-referencing table like
Using this definition of a URI <scheme name> : <hierarchical part> [ ? <query>
I need to create a join query for hierarchical data across 2 tables. These
I have a deep hierarchical model that looks like this: Accounts -> Venues ->Events

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.