我有2个LIST
List<PrimeraVueltaFindResult> ListaPrimeraVuelta = new List<PrimeraVueltaFindResult>();
List<RutaCriticaFindResult> result = new List<RutaCriticaFindResult>();
public class PrimeraVueltaFindResult
{
[DataMember]
public string Descripcion { get; set; }
[DataMember]
public string JobNameInicio { get; set; }
[DataMember]
public string GroupInicio { get; set; }
[DataMember]
public string StartRun { get; set; }
[DataMember]
public string JobNameFin { get; set; }
[DataMember]
public string GroupFin { get; set; }
[DataMember]
public string EndRun { get; set; }
}
public class RutaCriticaFindResult
{
[DataMember]
public int RutaCriticaId { get; set; }
[DataMember]
public string StartRun { get; set; }
[DataMember]
public string EndRun { get; set; }
}
我需要在PrimeraVueltaFindResult列表值中复制StartRun和EndRun。
请问我该怎么办?
答案 0 :(得分:4)
要将ListaPrimeraVuelta
中的所有数据复制到新的RutaCriticaFindResult
对象中,您可以使用LINQ:
var rutaCriticaFindResults = ListaPrimeraVuelta.Select(result =>
new RutaCriticaFindResult
{
StartRun = result.StartRun,
EndRun = result.EndRun
});
var result = rutaCriticaFindResults.ToList();