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.
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.
Q11: Can I use transactions with RS.Dapper.Utility?
A: Yes ✅. Starting from version 1.0.3, RS.Dapper.Utility supports transactions using the new transactionOn
flag. By setting transactionOn: true
, your insert, update, delete, or multiple operations will run inside a transaction, ensuring data consistency. If any operation fails, all changes will be rolled back automatically.
Example:
Q12: What is the purpose of the transactionOn
flag in RS.Dapper.Utility?
A: The transactionOn
flag allows developers to control whether an operation (insert, update, delete, or batch execution) should run inside a database transaction. When set to true
, all operations in that block will be executed within a transaction — ensuring that either all succeed or all fail (rollback). When set to false
, the operation runs without a transaction, which can be faster for simple, independent queries.
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.
Hire me on Linkedin
My portfolio