we make two table
first one is
public class Group
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string LegalBusinessName { get; set; }
public string Tin { get; set; }
public string CCN { get; set; }
public int PartnerId { get; set; }
public long AddressId { get; set; }
public bool IsMIPS { get; set; }
public int EntityTypeId { get; set; }
public bool CalcPiScore { get; set; }
public bool CalcQualityScore { get; set; }
public bool CalcCpiaScore { get; set; }
public bool IsActive { get; set; }
//relation Table for one to one mappin
public Address Address { get; set; }
}
and second table is
public class Address
{
public long Id { get; set; }
public string line1 { get; set; }
public string line2 { get; set; }
public string line3 { get; set; }
public string City { get; set; }
public string State { get; set; }
public int Zip { get; set; }
public Group Groups { get; set; }
}
one table is group and the second table is the address, define one to one mapping
builder.HasOne(a => a.Address).WithOne(b => b.Groups).HasForeignKey<Group>(f => f.AddressId).OnDelete(DeleteBehavior.NoAction);
now I make a othe class D_group
public class D_Group
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string LegalBusinessName { get; set; }
public string Tin { get; set; }
public string CCN { get; set; }
public int PartnerId { get; set; }
public long AddressId { get; set; }
public bool IsMIPS { get; set; }
public int EntityTypeId { get; set; }
public bool CalcPiScore { get; set; }
public bool CalcQualityScore { get; set; }
public bool CalcCpiaScore { get; set; }
public bool IsActive { get; set; }
public string line1 { get; set; }
public string line2 { get; set; }
public string line3 { get; set; }
public string City { get; set; }
public string State { get; set; }
public int Zip { get; set; }
}
i want fetch the data we can fetch the data but address table data com null like line1, line2 etc
public async Task<Response<IList<D_Group>>> GroupList()
{
var groups = await _context.Group.ToListAsync();
return _mapper.Map<Response<IList<D_Group>>>(groups);
}
how can i achieve it