I have a object of class 'PersonnelVehicle' which has structure as below:
public class PersonnelVehicle
{
private Guid _personnelId;
public Guid PersonnelId
{
get
{
return _personnelId;
}
}
private int _Age;
public int Age
{
get
{
return _Age;
}
}
private string _personnelName;
public string PersonnelName
{
get
{
return _personnelName;
}
}
}
I know how to fetch single element using lambda expression
i.e ObjectPersonnel.Select(x=>x.PersonnelId)
1) But how to fetch multiple elements
i.e Age and PersonnelName from this object using Lambda expression?
2) Also, if I have structure for PersonnelVehicle as below,
public class PersonnelVehicle
{
public ObservableCollection<PersonnelModel> Personnel_List = new ObservableCollection<PersonnelModel>
{
new PersonnelModel{ID=Guid.NewGuid(),Name="Mr.Joe",Gender="Male",Hospital="Poly Clinic",EMPID="abc 123",Capabilities="123",Position="Assistant",Title="Test",Status="General",ICNumber="IC 123",Roles="Test"},
new PersonnelModel{ID=Guid.NewGuid(),Name="Su Su",Gender="Female",Hospital="Clementi Clinic",EMPID="abc 1234",Capabilities="1234",Position="Security",Title="Test",Status="General",ICNumber="IC 1234",Roles="Test"},
new PersonnelModel{ID=Guid.NewGuid(),Name="Ms Tan",Gender="Female",Hospital="Bishan Clinic",EMPID="abc 1235",Capabilities="1235",Position="HR",Title="Test",Status="General",ICNumber="IC 1235",Roles="Test"},
};
}
How to fetch all the list of IDs and Positions using same way?
Note: I need only in Lambda expressions, so its different question from this link: Linq Syntax - Selecting multiple columns