I have a model that is not very simple and straightforward and I want to get certain data from it but I am not too familiar with Linq or what command to use. Here is the model code:
public class RootObject
{
public string _id { get; set; }
public string court { get; set; }
public string type { get; set; }
public string caption { get; set; }
public Case cases { get; set; }
public Dates dates { get; set; }
public Judge judge { get; set; }
public Balance balance { get; set; }
public Sentence sentence { get; set; }
public List<Charge> charges { get; set; }
public List<Participant> participants { get; set; }
}
public class Participant
{
public string _id { get; set; }
public string type { get; set; }
public int partyNumber { get; set; }
public Name2 name { get; set; }
public Address address { get; set; }
public Phone phone { get; set; }
public Birth birth { get; set; }
public List<Cost> costs { get; set; }
public List<Receipt> receipts { get; set; }
}
public class Name2
{
public string prefix { get; set; }
public string first { get; set; }
public string middle { get; set; }
public string last { get; set; }
public string suffix { get; set; }
public string company { get; set; }
public string full { get; set; }
}
I am basically trying to get to the first and last name or full name in that Name2 class through the root object and participants list. I am using asp.net 5 and mvc 6 and linq to call the objects, but cannot seem to get the value due to my linq being incorrect. The model is passed as in IEnumerable list to the view class, and here is the code used to try and get the name:
@foreach (var item in Model)
{
@item.participants.Select(i => i.name.full);
}
Any help would be appreciated.
Thank you for your time