I have a poco model that looks like this:
public int Id {get; set;
public string EmailAddress { get; set; }
public int? GenderTypeId { get; set; }
public List<FindPersonResultsViewModel> findPersonResultsViewModel { get; set; }
The List FindPersonResultsViewModel contains
public string FirstName { get; set; }
public string LastName { get; set; }
At first on a Post I have the following data
public IActionResult FindPerson (FindPersonViewModel findPersonViewModel)
Id : 4432
EmailAddress: "johnsmith@test.com"
findPersonResultsViewModel : null
So what I want to do is hydrate this list view model with some dummy data ( I will add real data later...
Seems like I'm having trouble with knowing how to do this, new up a list of this ?
findPersonViewModel.findPersonResultsViewModel.Add({ ??
List<FindPersonResultsViewModel> findPersonResultsViewModel =
new List<FindPersonResultsViewModel>();
// How to add data , especially to that model that contains the list findPersonViewModel ??
You just need to do this:
I see no reason why this shouldn't work.
If all you want to do is add some data to the null list on your object, you can do something like this: