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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:02:49+00:00 2026-06-13T09:02:49+00:00

Can someone please explain the difference between Dapper.Rainbow vs. Dapper.Contrib ? I mean when

  • 0

Can someone please explain the difference between Dapper.Rainbow vs. Dapper.Contrib?

I mean when do you use SqlMapperExtensions.cs of Dapper.Contrib and when should you use Dapper.Rainbow?

  • 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-13T09:02:50+00:00Added an answer on June 13, 2026 at 9:02 am

    I’ve been using Dapper for a while now and have wondered what the Contrib and Rainbow projects were all about myself. After a bit of code review, here are my thoughts on their uses:

    Dapper.Contrib

    Contrib provides a set of extension methods on the IDbConnection interface for basic CRUD operations:

    • Get
    • Insert
    • Update
    • Delete

    The key component of Contrib is that it provides tracking for your entities to identify if changes have been made.

    For example, using the Get method with an interface as the type constraint will return a dynamically generated proxy class with an internal dictionary to track what properties have changed.

    You can then use the Update method which will generate the SQL needed to only update those properties that have changed.

    Major Caveat: to get the tracking goodness of Contrib, you must use an Interface as your type constraint to allow the proxy class to be generated.

    Dapper.Rainbow

    Rainbow is an Abstract class that you can use as a base class for your Dapper classes to provide basic CRUD operations:

    • Get
    • Insert
    • Update
    • Delete

    As well as some commonly used methods such as First (gets the first record in a table) and All (gets all results records in a table).

    For all intents and purposes, Rainbow is basically a wrapper for your most commonly used database interactions and will build up the boring SQL based on property names and type constraints.

    For example, with a Get operation, Rainbow will build up a vanilla SQL query and return all columns and then map those values back to the type used as the constraint.

    Similarly, the insert/update methods will dynamically build up the SQL needed for an insert/update based on the type constraint’s property names.

    Major Caveat: Rainbow expects all your tables to have an identity column named “Id”.

    Differences?

    The major difference between Contrib and Rainbow is (IMO), one tracks changes to your entities, the other doesn’t:

    • Use Contrib when you want to be able to track changes in your entities.
    • Use Rainbow when you want to use something more along the lines of a standard ADO.NET approach.

    On a side note: I wish I had looked into Rainbow earlier as I have built up a very similar base class that I use with Dapper.


    From the article and quote @anthonyv quoted: That annoying INSERT problem, getting data into the DB

    There are now 2 other APIs you can choose from as well (besides Rainbow) (for CRUD)
    Dapper.Contrib and Dapper Extensions.
    I do not think that one-size-fits-all. Depending on your problem and
    preferences there may be an API that works best for you. I tried to
    present some of the options. There is no blessed “best way” to solve
    every problem in the world.

    I suspect what Sam was trying to convey in the above quote and the related blog post was: Your scenario may require a lot of custom mapping (use vanilla Dapper), or it may need to track entity changes (use Contrib), or you may have common usage scenarios (use Rainbow) or you may want to use a combination of them all. Or not even use Dapper. YMMV.

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

Sidebar

Related Questions

Can someone please explain the difference between the following methods to me? it should
Can someone please explain to me difference between extends and super in java generics
Can someone please explain to me the difference between the AppSettings and ApplicationSettings sections
Can someone please explain with example that I can understand about the difference between
Can someone please explain the difference between ViewState and Session? More specifically, I'd like
Can someone please explain the difference between IE8 browser mode and document mode in
Can someone please explain what is the main difference between SQL Server Compact Edition
Can someone please explain the difference between the following queries. The joins in the
can someone please explain the difference between these 2 pieces of code: var temp
Can someone please explain the difference between the following cases and where would we

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.