Dapper постоянно возвращает значение по умолчанию вместо идентификатора. В чем может быть проблема и как ее исправить? (Dapper + PostgreSQL)
Можете ли вы объяснить мне, в чем проблема?
введите здесь описание изображения
Dapper постоянно возвращает значение по умолчанию вместо идентификатора. В чем может быть проблема и как ее исправить? (Dapper + PostgreSQL) Можете ли вы объяснить мне, в чем проблема? введите здесь описание изображения [code]public async Task GetByIdWithPatientAndDoctorAsync(Guid id) { await using var connection = new NpgsqlConnection(connectionString); await connection.OpenAsync(); const string query = """ select a.*, p.*, d.*, c.*, s.name as specializationname from appointments a inner join patients p on a.patientid = p.id inner join doctors d on a.doctorid = d.id inner join clinics c on a.clinicid = c.id inner join specializations s on d.specializationid = s.id where a.id = @Id """;
var appointments = await connection.QueryAsync( query, (appointment, patient, doctor, clinic, specialization) => { appointment.Patient = patient; doctor.Specialization = specialization; appointment.Doctor = doctor; appointment.Clinic = clinic; return appointment; }, new { Id = id }, splitOn: "id, id, id, specializationname");
return appointments.FirstOrDefault(); } public class Appointment : Entity { public Appointment() {} public Appointment(DateTime date, Guid patientId, Guid doctorId, Guid clinicId, AppointmentStatus appointmentStatus) { Date = date; PatientId = patientId; DoctorId = doctorId; ClinicId = clinicId; AppointmentStatus = appointmentStatus; }
public DateTime Date { get; set; } public Guid PatientId { get; set; } public Patient Patient { get; set; } public Guid DoctorId { get; set; } public Doctor Doctor { get; set; } public Guid ClinicId { get; set; } public Clinic Clinic { get; set; } public AppointmentStatus AppointmentStatus { get; set; } } public abstract class Entity { protected Entity() {}
protected Entity(Guid id) { Id = id; }
public Guid Id { get; } } [/code] Я уже пробовал играть со сплитоном и вводить идентификатор в другое имя, ничего не помогло