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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:27:24+00:00 2026-06-01T00:27:24+00:00

On Dapper’s documentation found here it states: Limitations and caveats Dapper caches information about

  • 0

On Dapper’s documentation found here it states:

Limitations and caveats

Dapper caches information about every query it runs, this allow it to materialize objects quickly and process parameters quickly. The current implementation caches this information in a ConcurrentDictionary object.

What exactly does this mean?
Ex: Is it caching returned data, or the query itself, or bits of both?

It also says that "this [cached] data is never flushed". How does this effect the "cached information" if the design schema of the table(s) you are querying is changed?

  • 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-01T00:27:26+00:00Added an answer on June 1, 2026 at 12:27 am

    As far as I know has each query you issue an Identity, depending on the sql query, its command type and its parameters. The cache is a dictionary with concurrent access.

    Dictionary<Identity, CacheInfo> _queryCache
    

    This CacheInfo object contains the IDataReader and IDBCommand functions and some control counters which limit the cached amount.

    Since no server-side (database schema etc.) are cached, it actually doesn’t have any influence.

    Edit: Thats how the Identity class looks like used for caching.

    private Identity(string sql, CommandType? commandType, string connectionString, Type type, Type parametersType, Type[] otherTypes, int gridIndex)
            {
                this.sql = sql;
                this.commandType = commandType;
                this.connectionString = connectionString;
                this.type = type;
                this.parametersType = parametersType;
                this.gridIndex = gridIndex;
                unchecked
                {
                    hashCode = 17; // we *know* we are using this in a dictionary, so pre-compute this
                    hashCode = hashCode * 23 + commandType.GetHashCode();
                    hashCode = hashCode * 23 + gridIndex.GetHashCode();
                    hashCode = hashCode * 23 + (sql == null ? 0 : sql.GetHashCode());
                    hashCode = hashCode * 23 + (type == null ? 0 : type.GetHashCode());
                    if (otherTypes != null)
                    {
                        foreach (var t in otherTypes)
                        {
                            hashCode = hashCode * 23 + (t == null ? 0 : t.GetHashCode());
                        }
                    }
                    hashCode = hashCode * 23 + (connectionString == null ? 0 : connectionString.GetHashCode());
                    hashCode = hashCode * 23 + (parametersType == null ? 0 : parametersType.GetHashCode());
                }
            }
    

    And here’s the CacheInfo

    class CacheInfo
    
            {
                public Func<IDataReader, object> Deserializer { get; set; }
                public Func<IDataReader, object>[] OtherDeserializers { get; set; }
                public Action<IDbCommand, object> ParamReader { get; set; }
                private int hitCount;
                public int GetHitCount() { return Interlocked.CompareExchange(ref hitCount, 0, 0); }
                public void RecordHit() { Interlocked.Increment(ref hitCount); }
            }
    

    And finally the container of the cache.

    static readonly System.Collections.Concurrent.ConcurrentDictionary<Identity, CacheInfo> _queryCache = new System.Collections.Concurrent.ConcurrentDictionary<Identity, CacheInfo>();
    

    Have a look at the source code, its very well written and easy to follow / debug. Just drag the file into your project.

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

Sidebar

Related Questions

Can someone please explain what this means (from the Dapper.net website) Limitations and caveats
Here on this page, Scott Hanselman shows two examples from Micro-ORMs Dapper and Massive,
We're thinking about moving over to Mono and I see that Dapper works with
(This code is using Dapper Dot Net in C#) This code works: var command
All the samples online show that Dapper.net works with SQL Server. What about other
Where can I find more information on connection pooling with Dapper.net?
I am giving the Dapper ORM a try. I am able to query data
What is the best way to write a query with IN clause using Dapper
Dapper can pass query parameters as anonymous objects, and supports any ADO.NET data provider.
I am wanting to use the MVCMiniProfiler with Dapper. Is this possible beyond wrapping

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.