Resolve "Evaluate .NET MAUI" #70

Merged
thorsten merged 42 commits from 34-evaluate-net-maui into main 2022-09-17 07:21:22 +00:00
Showing only changes of commit 7b149417e7 - Show all commits
+19
View File
@@ -38,6 +38,25 @@ public static class Setup
serviceCollection.AddDbContext<DataContext>(options => options.UseSqlite($"Filename={path2DataFile};Mode={(createWhenNecessary ? DB_READ_WRITE_CREATE_MODE : DB_READ_WRITE_MODE)};"), ServiceLifetime.Transient); serviceCollection.AddDbContext<DataContext>(options => options.UseSqlite($"Filename={path2DataFile};Mode={(createWhenNecessary ? DB_READ_WRITE_CREATE_MODE : DB_READ_WRITE_MODE)};"), ServiceLifetime.Transient);
} }
/// <summary>
/// Create the database instance from the given path.
/// </summary>
public static DataContext CreateDatabaseInstance(string path2DataFile, bool createWhenNecessary = true)
{
// Store the path to the database:
Setup.usedDataFile = path2DataFile;
// Create a database builder:
var builder = new DbContextOptionsBuilder<DataContext>();
// Add the database configuration to the builder:
builder.UseSqlite($"Filename={path2DataFile};Mode={(createWhenNecessary ? DB_READ_WRITE_CREATE_MODE : DB_READ_WRITE_MODE)};");
// Next, construct the database context:
var dbContext = new DataContext(builder.Options);
return dbContext;
}
/// <summary> /// <summary>
/// Sets up the DI & db context ready for the EF tooling. /// Sets up the DI & db context ready for the EF tooling.
/// </summary> /// </summary>