-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b92607
commit b81f7ba
Showing
78 changed files
with
578 additions
and
510 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
// This is an independent project of an individual developer. Dear PVS-Studio, please check it. | ||
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com | ||
//// This is an independent project of an individual developer. Dear PVS-Studio, please check it. | ||
//// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com | ||
|
||
namespace TgDownloaderBlazor.Utils; | ||
//namespace TgDownloaderBlazor.Utils; | ||
|
||
public static class TgDatabaseUtility | ||
{ | ||
// Method to see the database. Should not be used in production: demo purposes only. | ||
// options: The configured options. | ||
// count: The number of contacts to seed. | ||
public static async Task EnsureDbCreatedAndSeedWithCountOfAsync(DbContextOptions<TgEfContext> options, int count) | ||
{ | ||
#if DEBUG | ||
Console.WriteLine($"EnsureDbCreatedAndSeedWithCountOfAsync"); | ||
#endif | ||
// Empty to avoid logging while inserting (otherwise will flood console). | ||
LoggerFactory factory = new(); | ||
DbContextOptionsBuilder<TgEfContext> builder = new DbContextOptionsBuilder<TgEfContext>() | ||
.UseLoggerFactory(factory) | ||
.UseSqlite($"{TgLocaleHelper.Instance.SqliteDataSource}={TgAppSettingsHelper.Instance.AppXml.FileStorage}"); | ||
await using var efContext = new TgEfContext(builder.Options); | ||
#if DEBUG | ||
Console.WriteLine(efContext.Database.GetConnectionString()); | ||
#endif | ||
//public static class TgDatabaseUtility | ||
//{ | ||
// // Method to see the database. Should not be used in production: demo purposes only. | ||
// // options: The configured options. | ||
// // count: The number of contacts to seed. | ||
// public static async Task EnsureDbCreatedAndSeedWithCountOfAsync(DbContextOptions<TgEfContext> options, int count) | ||
// { | ||
//#if DEBUG | ||
// Console.WriteLine($"EnsureDbCreatedAndSeedWithCountOfAsync"); | ||
//#endif | ||
// // Empty to avoid logging while inserting (otherwise will flood console). | ||
// LoggerFactory factory = new(); | ||
// DbContextOptionsBuilder<TgEfContext> builder = new DbContextOptionsBuilder<TgEfContext>() | ||
// .UseLoggerFactory(factory) | ||
// .UseSqlite(b => b.MigrationsAssembly(nameof(TgDownloaderBlazor))) | ||
// .UseSqlite($"{TgLocaleHelper.Instance.SqliteDataSource}={TgAppSettingsHelper.Instance.AppXml.FileStorage}") | ||
// ; | ||
// await using var efContext = new TgEfContext(builder.Options); | ||
//#if DEBUG | ||
// Console.WriteLine(efContext.Database.GetConnectionString()); | ||
//#endif | ||
|
||
// Result is true if the database had to be created. | ||
//if (await efContext.Database.EnsureCreatedAsync()) | ||
//{ | ||
// //var seed = new SeedContacts(); | ||
// //await seed.SeedDatabaseWithContactCountOfAsync(context, count); | ||
// List<TgEfProxyEntity> proxies = efContext.Proxies.Select(x => x).Take(1).ToList(); | ||
//} | ||
} | ||
} | ||
// // Result is true if the database had to be created. | ||
// //if (await efContext.Database.EnsureCreatedAsync()) | ||
// //{ | ||
// // //var seed = new SeedContacts(); | ||
// // //await seed.SeedDatabaseWithContactCountOfAsync(context, count); | ||
// // List<TgEfProxyEntity> proxies = efContext.Proxies.Select(x => x).Take(1).ToList(); | ||
// //} | ||
// } | ||
//} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.