Files
the-biergarten-app/DataAccessLayer/Sql/DatabaseHelper.cs
Aaron Po b8cd855916 Refactor user entities and repositories, update seeders
Standardized property naming in user-related entities to use 'Id' suffix (e.g., UserAccountId). Moved and updated repository interfaces and implementations to the DataAccessLayer.Repositories namespace. Refactored DBSeed seeders to use repository classes and improved structure. Updated .gitignore and project references
2026-01-15 13:23:41 -05:00

42 lines
1.1 KiB
C#

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}");
}
}
}
}