My (legacy, can't be changed) schema has a one-to-one relationship between User and UserAddress, with a composite key:
Users:
- username (PK)
- email (PK)
- firsname
- lastname
UsersAddresses:
- username (PK, FK)
- email (PK, FK)
- city
- street
My original idea was to use a <join
to bring them all to the same class:
public class UserDTO
{
public string Username { get; set; }
public string Email { get; set; }
public string FirstName { get; set; }
public string City { get; set; }
//etc...
}
but I don't know about the mapping:
Join("UsersAddresses", j=>
{
j.Table("UsersAddresses");
j.Fetch(FetchKind.Join);
j.Optional(false);
j.Key(k=>
{
//What here???
k.Column(c=>
{
c.Name("");
c.Name("");
});
k.ForeignKey("");
k.ForeignKey("");
});
});
Is there a way to achieve this? Or perhaps I should opt for a component or a one-to-one mapping...