I have 2 entities which the People and Contact
- public class People{
- [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public Guid Id { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- }
- public class Contact{
- [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public Guid Id { get; set; }
- public Guid PeopleId { get; set; }
- public string Type { get; set; }
- public string ContactNumber { get; set; }
- }
and I have the model ContactModel to display the entity.
- public class ContactModel{
- public Guid Id { get; set; }
- public Guid PeopleId { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string Type { get; set; }
- public string ContactNumber { get; set; }
- }
my problem is when I'm trying to map the entities to model, I can only map the People entity or one entity and the the two entities.
- public static ContactModel ToModel(this People people){
- return new ContactModel{
- Id = people.Id,
- FirstName = people.FirstName,
- LastName = people.LastName
- };
- }