Заменил название колонки первичного ключа в запросах
This commit is contained in:
parent
1907b56478
commit
ff0b60f3bd
@ -17,8 +17,8 @@ namespace MedicalPostgresqlDatabase.Storages
|
||||
{
|
||||
return new Diagnose
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Name = reader.GetString(1),
|
||||
Id = Convert.ToInt32(reader.GetOrdinal(PRIMARY_KEY_COLUMN_NAME)),
|
||||
Name = Convert.ToString(reader.GetOrdinal("name")),
|
||||
};
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ namespace MedicalPostgresqlDatabase.Storages
|
||||
{
|
||||
using var connection = GetConnection();
|
||||
connection.Open();
|
||||
using var cmd = new NpgsqlCommand("INSERT INTO diagnoses (diagnose_id, name) VALUES ((nextval('diagnoses_id_seq')), @name)", connection);
|
||||
using var cmd = new NpgsqlCommand($"INSERT INTO diagnoses ({PRIMARY_KEY_COLUMN_NAME}, name) VALUES ((nextval('diagnoses_id_seq')), @name)", connection);
|
||||
cmd.Parameters.AddWithValue("@name", item.Name);
|
||||
Stopwatch stopwatch = new();
|
||||
stopwatch.Start();
|
||||
@ -39,7 +39,7 @@ namespace MedicalPostgresqlDatabase.Storages
|
||||
{
|
||||
using var connection = GetConnection();
|
||||
connection.Open();
|
||||
using var cmd = new NpgsqlCommand("UPDATE diagnoses SET name = @name WHERE diagnose_id = @id", connection);
|
||||
using var cmd = new NpgsqlCommand($"UPDATE diagnoses SET name = @name WHERE {PRIMARY_KEY_COLUMN_NAME} = @id", connection);
|
||||
cmd.Parameters.AddWithValue("@id", item.Id);
|
||||
cmd.Parameters.AddWithValue("@name", item.Name);
|
||||
Stopwatch stopwatch = new();
|
||||
|
@ -30,7 +30,7 @@ namespace MedicalPostgresqlDatabase.Storages
|
||||
{
|
||||
using var connection = GetConnection();
|
||||
connection.Open();
|
||||
using var cmd = new NpgsqlCommand("INSERT INTO doctors (doctor_id, name, surname, patronymic, phone_number, specialization_id) VALUES ((nextval('doctors_id_seq')), @name, @surname, @patronymic, @phone_number, @specialization_id)", connection);
|
||||
using var cmd = new NpgsqlCommand($"INSERT INTO doctors ({PRIMARY_KEY_COLUMN_NAME}, name, surname, patronymic, phone_number, specialization_id) VALUES ((nextval('doctors_id_seq')), @name, @surname, @patronymic, @phone_number, @specialization_id)", connection);
|
||||
cmd.Parameters.AddWithValue("@name", item.Name);
|
||||
cmd.Parameters.AddWithValue("@surname", item.Surname);
|
||||
cmd.Parameters.AddWithValue("@patronymic", item.Patronymic);
|
||||
|
Loading…
Reference in New Issue
Block a user