Reputation: 629
I found this site https://blogs.msdn.microsoft.com/dotnet/2016/11/09/net-core-data-access/ but if I can use one variable to holed the different connection? For example I have MySQL and SQLite. So I write var connection = new SqliteConnection()
and var connection = new MySqlConnection()
but I need this variable connection
as argument for functions. Can I somehow make it? And object
does not help :(
Upvotes: 0
Views: 734
Reputation: 100731
Both SqliteConnection
and MySqlConnection
inherit from DbConnection
which you can use as parameter type. For even more abstraction: this type also implements IDbConnection
Upvotes: 1