I cant built a complex object with a query. How I do?
public class Person
{
public long Id { get; set; }
public string Name { get; set; }
public Contact Contact { get; set; }
}
public class Contact
{
public long Id { get; set; }
public string FoneNumber { get; set; }
}
As you have wrote before, use the Join Method to join with the "Contact" table,
var row = db.Query("Person")
.Select(
"Person.Id",
"Person.Name",
"Contact.Id as ContactId",
"Contact.FoneNumber as FoneNumber"
)
.Join("Contact", "Person.Id", "Contact.PersonId")
.Where("Person.Id", 1)
.FirstOrDefault();