예제 4-19 Repository 인터페이스의 SQL 서버 구현
(Restaurant/c82d82c/Restaurant.RestApi/SqlReservationsRepository.cs)
public class SqlReservationsRepository : IReservationsRepository
{
public SqlReservationsRepository( string connectionString)
{
ConnectionString = connectionString;
}
public string ConnectionString { get; }
public async Task Create(Reservation reservation)
{
if (reservation is null)
throw new ArgumentNullException(nameof(reservation));
using var conn = new SqlConnection(ConnectionString);
using var cmd = new SqlCommand(createReservationSql, conn);
cmd.Parameters.Add( new SqlParameter("@At", reservation.At));
cmd.Parameters.Add( new SqlParameter("@Name", reservation.Name));
cmd.Parameters.Add( new SqlParameter("@Email", reservation.Email));
cmd.Parameters.Add(
new SqlParameter("@Quantity", reservation.Quantity));