I have an array of database entities that I need to convert to some different class in order to serve as a REST request result:
DatabaseDTO[] arrayFromDb = _repo.GetAllData();
OutgoinDTO[] = convertFromDatabaseDTO (arrayFromDb);
what is the most efficient way to do so (I assume that OutgoingDTO has a constructor that takes DatabaseDTO)
Array.ConvertAll()will do the trick? This is likely to be optimally efficient.IEnumerableinstead of an array.DatabaseDTO[] arrayFromDb = _repo.GetAllData(); OutgoinDTO[] = Array.ConvertAll(arrayFromDb, x => new OutgoinDTO(x));