mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 18:52:06 +00:00
Update repository, seed and service layers
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace DataAccessLayer.Sql
|
||||
{
|
||||
public class DatabaseHelper(string connectionString)
|
||||
{
|
||||
public void ExecuteRawSql(string query)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var connection = new SqlConnection(
|
||||
connectionString
|
||||
);
|
||||
|
||||
connection.Open();
|
||||
|
||||
using var command = new SqlCommand(query, connection);
|
||||
|
||||
command.CommandType = CommandType.Text;
|
||||
|
||||
using var reader = command.ExecuteReader();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
for (var i = 0; i < reader.FieldCount; i++)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"{reader.GetName(i)}: {reader.GetValue(i)}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"An error occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
DataAccessLayer/Sql/ISqlConnectionFactory.cs
Normal file
9
DataAccessLayer/Sql/ISqlConnectionFactory.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace DataAccessLayer.Sql
|
||||
{
|
||||
public interface ISqlConnectionFactory
|
||||
{
|
||||
SqlConnection CreateConnection();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user