RS Dapper Utility FAQ

RS Dapper Utility FAQ

📝 FAQ: Managing Multiple Databases in C# with RS.Dapper.Utility

When working with Dapper in enterprise applications, developers often need to support multiple databases such as SQL Server, PostgreSQL, and MySQL. Managing connections, schemas, and configurations can quickly get complicated.

That’s where RS.Dapper.Utility (and specifically DatabaseResolver) comes in. Below we’ve compiled a quick FAQ guide to help you understand and use it effectively.

❓ FAQ

Q1: What is RS.Dapper.Utility?
RS.Dapper.Utility is a lightweight utility library built on top of Dapper to simplify and standardize database operations across SQL Server, PostgreSQL, and MySQL.


Q2: How do I configure my databases?
All databases are managed via appsettings.json. You just need to define connection strings and database types under the Databases section.

{
  "Databases": {
    "UsersDb": {
      "DbType": "SqlServer",
      "ConnectionString": "Server=...;Database=UsersDb;User Id=...;Password=...;"
    },
    "CategoriesDb": {
      "DbType": "PostgreSql",
      "ConnectionString": "Host=...;Database=CategoriesDb;Username=...;Password=...;"
    },
    "OrdersDb": {
      "DbType": "MySql",
      "ConnectionString": "Server=...;Database=OrdersDb;Uid=...;Pwd=...;"
    }
  }
}


Q3: What is DbSchema.cs and why do I need it?

  • DbSchema.cs serves as a bridge between your application code and RS.Dapper.Utility.

  • It centralizes database names, schemas, and table mappings to ensure consistency and maintainability.

  • Developers manage this class directly to add new tables, procs, or schemas.


Q4: Do I need to use stored procedures?
Not always.

  • For 95% of CRUD operations, use IDapperRepository (insert, update, delete, select, paging).

  • For complex queries across multiple tables, you can still use stored procedures with IDapperExecutor.


Q5: Can I switch databases easily (SQL Server ↔ MySQL ↔ PostgreSQL)?
Yes ✅.

  • If your app uses only IDapperRepository, switching databases takes about 5 minutes.

  • If you use both IDapperRepository (95%) and IDapperExecutor (5% stored procedures), it usually takes about 1 hour.


Q6: Does RS.Dapper.Utility support dependency injection?
Yes. You just register it in Program.cs like this:
DbSchema.Initialize(builder.Configuration);
builder.Services.RS_DapperUtilityDependencyInjections(builder.Configuration);


Q7: How do I use attributes like [IgnoreOnInsert] or [SqlParam]?

  • [IgnoreOnInsert] → Skips properties during insert (useful for auto-generated Ids).

  • [SqlParam("column_name")] → Maps C# property names to DB column names or stored procedure parameters.

[IgnoreOnInsert] 
public long Id { get; set; }

[SqlParam("Icon")] 
public string Image { get; set; }

Q8: Can I use RS.Dapper.Utility for paging and search?
Yes 🚀.

  • GetPagedDataAsync lets you run paged queries.

  • You can also define custom search columns for filtering.


Q9: Do I need to install anything besides Dapper?
No. Just install RS.Dapper.Utility from NuGet:
dotnet add package RS.Dapper.Utility


Q10: Is RS.Dapper.Utility open source?
Yes ✅.

  • It’s licensed under MIT.

  • You can contribute, customize, and enhance it.

  • Full source code is available here: RS.Dapper.Utility on GitHub.

 


Thanks, for reading the blog, I hope it helps you. Please share this link on your social media accounts so that others can read our valuable content. Share your queries with our expert team and get Free Expert Advice for Your Business today.


About Writer

Ravinder Singh

Full Stack Developer
I have 15+ years of experience in commercial software development. I write this blog as a kind of knowledge base for myself. When I read about something interesting or learn anything I will write about it. I think when writing about a topic you concentrate more and therefore have better study results. The second reason why I write this blog is, that I love teaching and I hope that people find their way on here and can benefit from my content.

Hire me on Linkedin

My portfolio

Ravinder Singh Full Stack Developer