Avoid the App.config file in the project when used with SQLite / SubSonic (or any other database)

I have a project that I am developing using SQLite and SubSonic 3. I want to know how to avoid the App.config file in general. How to tell my program that you are using a SQLite data provider. I mean, how can I say the following:

<DbProviderFactories>
    <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite">
</DbProviderFactories>

You can also add a connection string by code:

<add name="xyz" connectionString="Data Source=xyz.db" providerName="System.Data.SQLite"/>
+3
source share
2 answers

You can create the Provider manually by passing the connection string to:

var p = ProviderFactory.GetProvider("connectionstring", "System.Data.SqlClient");

, . IoC, SubSonic IDataProvider:

ForRequestedType< IDataProvider >()
    .TheDefault.Is.ConstructedBy(x => 
        ProviderFactory.GetProvider("connectionstring", "System.Data.SqlClient"));

IoC:)

+4

app.config, . .NET. ?

, ADO.NET .

, SQLite, , , DbProviderFactory.

+1

Source: https://habr.com/ru/post/1721194/


All Articles