I don’t understand why it isn’t mapping….PostgreSQL….Please help me who can….
It always returns an empty object in join and value objects
I have a little experience with dapper but i haven’t time for deep learning
public async Task<IEnumerable<Doctor>> Search(DoctorFilter filter)
{
await using var connection = new NpgsqlConnection(connectionString);
await connection.OpenAsync();
var query = BuildSearchParameters(filter, out var parameters);
var doctors = await connection.QueryAsync<Doctor, Specialization, Clinic, Doctor>(
query,
(doctor, specialization, clinic) =>
{
doctor.Specialization = specialization;
if (clinic != null)
{
doctor.Clinics.Add(clinic);
}
return doctor;
},
parameters,
splitOn: "SpecializationId, ClinicId"
);
return doctors;
}
public class Doctor : Entity
{
public Doctor()
{
Clinics = new List<Clinic>();
}
public Guid SpecializationId { get; set; }
public Specialization Specialization { get; set; }
public Qualification Qualification { get; set; }
public int Experience { get; set; }
public Guid? UserId { get; set; }
public User User { get; set; }
public FullName FullName { get; set; }
public List<Clinic> Clinics { get; set; }
}
namespace MedRaise.Domain.Entities;
public class Specialization : Entity
{
public string Name { get; set; }
}
using MedRaise.Domain.ValueObjects;
namespace MedRaise.Domain.Entities;
public class Clinic : Entity
{
public Clinic() {}
public Clinic(string name, Address address, ContactInformation contactInformation)
{
Name = name;
Address = address;
ContactInformation = contactInformation;
Doctors = new List<Doctor>();
}
public string Name { get; set; }
public Address Address { get; set; }
public ContactInformation ContactInformation { get; set; }
public List<Doctor> Doctors { get; set; }
}
I don’t understand how to solve this problem, I’ve already tried changing SplitOn and all sorts of advice from chat and internet and nothing helped