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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:33:19+00:00 2026-05-26T19:33:19+00:00

Out of curiosity i would like to know how to best implement a class

  • 0

Out of curiosity i would like to know how to best implement a class that could be used to avoid the CA1006 warning

CA1006 : Microsoft.Design : Consider a design where ‘IReader.Query(String, String)’ doesn’t nest generic type ‘IList(Of IDictionary(Of String, Object))’.

This is the method that returns the generic type

public virtual IList<IDictionary<string, object>> Query(
    string fullFileName, 
    string sheetName)
{
    using (var connection = new OdbcConnection(
        this.GetOdbcConnectionString(fullFileName)))
    {
        connection.Open();
        return connection
            .Query(string.Format(
                CultureInfo.InvariantCulture,
                SystemResources.ExcelReader_Query_select_top_128___from__0_,
                sheetName))
            .Cast<IDictionary<string, object>>()
            .ToList();
    }
}

Something like

SourceData<T, U> Query(string fullFileName, string sheetName)
SourceData Query(string fullFileName, string sheetName)

EDIT:

Following Marc’s suggestions I encapsulated the nested generic in this class

public class QueryRow : List<KeyValuePair<string, object>>
{
    protected internal QueryRow(IEnumerable<KeyValuePair<string, object>> dictionary)
    {
        this.AddRange(dictionary.Select(kvp => kvp));
    }
}
  • 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-26T19:33:20+00:00Added an answer on May 26, 2026 at 7:33 pm

    Firstly, note that it is a design guideline, not a compiler error. One valid approach here would be: ignore it.

    Another might be – encapsulate it; i.e. return a List<QueryRow>, where QueryRow is a shallow wrapper over an IDictionary<string,object> with an indexer, i.e.

    public class QueryRow {
        private readonly IDictionary<string,object> values;
        internal QueryRow(IDictionary<string,object> values) {
            this.values = values;
        }
        public object this[string key] {
            get { return values[key]; }
            set { values[key] = value; }
        }
    }
    

    then, since this is being accessed via dapper, fill via:

    var data = connection.Query(....)
            .Select(x => new QueryRow((IDictionary<string,object>)x).ToList()
    

    Another option (that I’m not hugely fond of), might be: return DataTable.

    goes off to wash his hands after typing DataTable… gah! twice now

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

Sidebar

Related Questions

i know how to write MSIL code but out of curiosity i would like
Mostly out of curiosity, I would like to know if there are any edge
Just out of curiosity, for applications that have a fairly complicated module tree, would
Out of curiosity, why are sometimes multiple Java .class files generated for a class
Out of curiosity is it possible to temporarily add a character that should be
This is a bit of a random question that is more out of curiosity
Not that I would want to use this practically (for many reasons) but out
Apparently, the following is the valid syntax: b'The string' I would like to know:
Out of curiosity (I just want to know how is it done in C#)
I started learning Standard ML recently out of curiosity. So what I know is

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.