I have the following :
class CarInspection
{
public CarInspectionAgenda Agenda {get;set;}
public string Description {get;set;}
...
}
class CarInspectionAgenda
{
public IList<DummyA> DummyAList {get;set;}
public string Name {get;set;}
...
}
class DummyAList
{
public DummyB DummyB {get;set;}
...
}
class DummyB
{
public string Name {get;set;}
...
}
Ok, so in my CarInspection View, I created a CarInspectionViewModel. I need to show a custom formatted string using the DummyB Names ...
So, I created that ViewModel :
public CarInspectionViewModel
{
public string Description {get;set;}
public CarInspectionAgendaViewModel Agenda {get;set;}
}
public CarInspectionAgendaViewModel
{
public string Name {get;set;}
public IList<string> DummyANameList {get;set;}
}
I tried something like that :
var list = carInspectionRepository.GetAll().Select(x => new CarInspectionViewModel()
{
Id = x.Id,
Description = x.Description,
Agenda = new AgendaFiscalizacaoVM
{
Id = x.CarInspectionAgenda.Id,
Name = x.CarInspectionAgenda.Name,
DummyANameList = x.CarInspectionAgenda.DummyAList.Select(y => y.DummyB.Name)
}
});
I got some weird results in DummyANameList ... I think that LINQ have something wrong... Any help?
Thanks