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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:32:56+00:00 2026-06-03T08:32:56+00:00

I am new to dapper and plan to use it on my new project.

  • 0

I am new to dapper and plan to use it on my new project. After reading it, seems like the only problem I might have is ConcurrentDictionary.

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. The objects
it stores are never flushed. If you are generating SQL strings on the
fly without using parameters it is possible you will hit memory
issues. We may convert the dictionaries to an LRU Cache.

How do I avoid this problem? Can someone please show me some code tell me how and when to flush it?

  • 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-03T08:32:57+00:00Added an answer on June 3, 2026 at 8:32 am

    Per the comments up top, here’s an example of on-the-fly:

    var builder = new StringBuilder();
    builder.AppendLine("SELECT Foo FROM Bar");
    if (fisrtName != null || lastName != null)
        builder.AppendLine("WHERE");
    if (firstName != null)
        builder.AppendLine("    Bar.FirstName = @Firstname");
    if (firstName != null && lastName != null)
        builder.Append(" AND");
    if (lastName != null)
        builder.AppendLine("    Bar.LastName = @LastName");
    var sql = builder.ToString();
    

    As you can see, the actual SQL that dapper will now run will be different based on whether or not firstName and/or lastName are null. If both are null, you get one SQL string. If only firstName is not null, you get another. If only lastName is not null, you get yet another. And finally, if both are not null you get a fourth permutation.

    This is what is meant by “on-the-fly” — dapper will cache based on these unique permutations, and given a more complex scenario, it is easy to see how you’ll end up with a great many different permutations, all of which would need to be cached independently.

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

Sidebar

Related Questions

NEW EDIT: I have narrowed my problem to this - i have a view
I've only just started looking at Dapper.net and have just been experimenting with some
I've just started using Dapper for a project, having mostly used ORMs like NHibernate
I have a problem with MultiMaps in dapper trying to split on column that
New to FluentNHibernate =D I have a parent/children classes as follows: public class Parent
New to Subsonic 3.0 and wondering how to perform LIKE operators on object attributes.
New to appfuse - I like the concept. I configured the username/password to the
I have a stored procedure that I'm trying to execute using Dapper that is
new to java and brand new to the site. I have a JLabel added
New to Git and just started to use Github. Just created my first public

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.