Reputation: 497
I could not find an example online where they showed you how to create mappings to multiple databases (in same application) based on which Unit Of Work you are using. Seems like Dapper Extensions will accept only one global SqlDialect
.
I want to use Dapper Extensions to map to multiple databases based on which Unit Of Work I am using. So for example for a UoW for repositories User
and UserLogin
, I want to map them to MySql. For a UoW for repositories Product
and Orders
, I want to map to Postgres. Both these mappings should work in same application at same time.
I'm not sure how to go about it since the SqlDialect
property seems to be a global setting.
Upvotes: 3
Views: 916
Reputation: 16389
The class DapperExtensions
is a static
class. Hence all members including SqlDialect
are static
. That is why the problem you mentioned in question. Even though global, if it was instance class/member, you could have simply created different instance but that is not possible due to the way DapperExtensions is designed.
This issue is reported on GitHub here.
Following may be possible solution.
If you want to use multiple implementations of DapperExtensions you can try using
impl := new DapperImplementor(new SqlGeneratorImpl(config));
I cannot explain more because I have never used this approach.
Upvotes: 3