Program.cs:
class Program { static void Main(string[] args) { DatabaseFactory databaseFactory = new DatabaseFactory(GetConfiguration()); IDatabase2 db = databaseFactory.GetDbObject(); var dt = db.ExecuteQueryDataTable("select * from product"); } static IConfigurationRoot GetConfiguration() { var builder = new ConfigurationBuilder() .SetBasePath(System.AppContext.BaseDirectory) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); return builder.Build(); } }appsettings.json:
{ "DefaultDb": "Context", "ContextProviderName": "MySql.Data.MySqlClient", "ConnectionStrings": { "Context": "Server=localhost;Database=db;Uid=root;Pwd=1234;" } }
No comments:
Post a Comment