To start, here are my classes:
public class Name
{
public int NameId {get;set;}
public string Value {get;set;}
[ForeignKey("Name_NameId")]
public ICollection<PersonName> PersonsName {get;set;}
}
public class NameType
{
public int NameTypeId {get;set;}
public string Value {get;set;}
[ForeignKey("NameType_NameTypeId")]
public ICollection<PersonName> PersonsName {get;set;}
}
public class Person
{
public int PersonId {get;set;}
public string Suffix {get;set;}
public datetime DateOfBirth {get;set;}
[ForeignKey("Person_PersonId")]
public ICollection<PersonName> PersonsName {get;set;}
}
public class PersonName
{
public int Person_PersonId {get;set;}
public int Name_NameId {get;set;}
public int NameType_NameTypeId {get;set;}
public int Order {get;set;}
}
Ideally, when accessing the Person class, I'd like to be able to call a function (or property) that could pull the person's full name from the PersonName repository. However, I'm not quite sure how to do that. For an example of data in these tables:
NameId Value
1 John
2 Jacob
3 Jingleheimer
4 Schmidt
NameTypeId Value
1 First Name
2 Middle Name
3 Last Name
4 Nickname
PersonId Suffix DateOfBirth
1 01/01/1900
Person_PersonId Name_NameId NameType_NameTypeId Order
1 1 1 0
1 2 2 0
1 3 2 1
1 4 3 0
So in the Person class, I'd like to have a function/property like GetFullName()/FullName where it would return "John Jacomb Jingleheimer Schmidt". I've been working through a tutorial from scratch and after making each class they then make an interface, mockrepository and are working on a db repository. However, I'd like to pass the information into a view via a View Model, but I'm not sure how to tie the class to the repository, etc. Is there anyone that can either point me to a tutorial that can explain that best or spell it out for me? Thanks.