PI06 i PI06-1. Docker definitions for MSSQL and Postgres. Data seeder/generator for countries and people. Entity Framework example with variants for Postgres and MSSQL

This commit is contained in:
Boris Milašinović
2026-04-19 16:49:07 +02:00
parent 44a663e170
commit 6f56d107a2
89 changed files with 7305 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
using Microsoft.Extensions.Configuration;
using Secrets;
var enumerator = Environment.GetEnvironmentVariables().GetEnumerator();
while (enumerator.MoveNext())
{
Console.WriteLine($"{enumerator.Key} = {enumerator.Value}");
}
Console.WriteLine("----------------------------");
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json") //order is important!
.AddJsonFile("missing_one.json", optional: true) //
.AddEnvironmentVariables() // include Package Microsoft.Extensions.Configuration.EnvironmentVariables
.AddUserSecrets("PI-Secrets") //package Microsoft.Extensions.Configuration.UserSecrets
.Build();
Console.WriteLine($"Custom env variable using configuration = " + configuration["CustomEnvValue"]);
Console.WriteLine($"Name = " + configuration["Name"]);
Console.WriteLine($"Key0 = " + configuration["Demo:Key0"]); //or Demo__Key0
Demo? demo = configuration.GetSection("Demo").Get<Demo>(); // package Microsoft.Extensions.Configuration.Binder
Console.WriteLine($"Key1 = " + demo?.Key1);
Console.WriteLine($"Key2 = " + demo?.Key2);