Last active
June 30, 2021 07:19
-
-
Save gistlyn/d4f31771aa8e93c3108909b48e96debb to your computer and use it in GitHub Desktop.
mixtemplates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AppHost : AppHostBase | |
{ | |
public AppHost() : base("Web",typeof(MyServices).Assembly){} | |
// Configure your AppHost with the necessary configuration | |
// and dependencies your App needs | |
public override void Configure(Container container) | |
{ | |
SetConfig(new HostConfig { | |
DebugMode = AppSettings.Get( | |
nameof(HostConfig.DebugMode), false) | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConfigureDb : IConfigureServices,IConfigureAppHost | |
{ | |
IConfiguration config { get; } | |
public ConfigureDb(IConfiguration configuration) => | |
config = configuration; | |
public void Configure(IServiceCollection services) | |
{ | |
services.AddSingleton<IDbConnectionFactory>( | |
new OrmLiteConnectionFactory( | |
config.GetConnectionString("DefaultConnection") | |
?? ":memory:", | |
SqliteDialect.Provider)); | |
} | |
public void Configure(IAppHost appHost) | |
{ | |
appHost.GetPlugin<SharpPagesFeature>()? | |
.ScriptMethods.Add(new DbScriptsAsync()); | |
// Create non-existing Table and add Seed Data Example | |
// using var db = appHost | |
// .Resolve<IDbConnectionFactory>().Open(); | |
// if (db.CreateTableIfNotExists<MyTable>()) { | |
// db.Insert(new MyTable { Name = "Seed Data" }); | |
// } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment