30 lines
828 B
C#
30 lines
828 B
C#
using Microsoft.Data.Sqlite;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace trakker.Data
|
|
{
|
|
public class DataAccess(string connectionString)
|
|
{
|
|
private readonly string _connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString));
|
|
|
|
/// <summary>
|
|
/// Creates a new, unopened SqliteConnection.
|
|
/// </summary>
|
|
protected SqliteConnection CreateConnection() => new(_connectionString);
|
|
|
|
/// <summary>
|
|
/// Opens and returns a SqliteConnection (synchronous).
|
|
/// </summary>
|
|
protected SqliteConnection OpenConnection()
|
|
{
|
|
var conn = CreateConnection();
|
|
conn.Open();
|
|
return conn;
|
|
}
|
|
}
|
|
}
|