AppDbContext: Add ExecuteBatch() and ExecuteScalar()
This commit is contained in:
@ -100,6 +100,18 @@ namespace Elwig.Helpers {
|
||||
return cnx;
|
||||
}
|
||||
|
||||
public static async Task ExecuteBatch(SqliteConnection cnx, string sql) {
|
||||
using var cmd = cnx.CreateCommand();
|
||||
cmd.CommandText = sql;
|
||||
await (await cmd.ExecuteReaderAsync()).CloseAsync();
|
||||
}
|
||||
|
||||
public static async Task<object?> ExecuteScalar(SqliteConnection cnx, string sql) {
|
||||
using var cmd = cnx.CreateCommand();
|
||||
cmd.CommandText = sql;
|
||||
return await cmd.ExecuteScalarAsync();
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
||||
optionsBuilder.UseSqlite(ConnectionString);
|
||||
optionsBuilder.UseLazyLoadingProxies();
|
||||
|
Reference in New Issue
Block a user