mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
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
This commit is contained in:
@@ -4,45 +4,31 @@ using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace DataAccessLayer.Sql
|
||||
{
|
||||
public class DatabaseHelper
|
||||
public class DatabaseHelper(string connectionString)
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
|
||||
public DatabaseHelper(string connectionString)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
}
|
||||
|
||||
public void ExecuteRawSql(string query)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (
|
||||
SqlConnection connection = new SqlConnection(
|
||||
_connectionString
|
||||
)
|
||||
)
|
||||
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())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
using (
|
||||
SqlCommand command = new SqlCommand(query, connection)
|
||||
)
|
||||
for (var i = 0; i < reader.FieldCount; i++)
|
||||
{
|
||||
command.CommandType = CommandType.Text;
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
for (int i = 0; i < reader.FieldCount; i++)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"{reader.GetName(i)}: {reader.GetValue(i)}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine(
|
||||
$"{reader.GetName(i)}: {reader.GetValue(i)}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user