1
僞例如C#是否支持「嵌套」過程產生一個IEnumerable?
public HttpResponseMessage GetAll() {
List<MyEntity> before = MyEntityRepository.GetAll();
return Request.CreateResponse(HttpStatusCode.OK,
new IEnumerable<MyExtendedEntity>({
before.ForEach(x =>
yield return new ExtendedEntity {
Property1 = x.Property1,
Property2 = x.Property2,
ExtendedProp = ExtendedPropProvider.getExtended(x)
})
);
哇,爲什麼我沒有想過呢?簡單明瞭。謝謝。 – Acrotygma