Here is a simplified example of how the functional programming style of Linq has impacted the way I would do a DDD service implementation.
Before:
IEnumerable<TDomainEntity> domainEntities = Repository.Find(criteria); IEnumerable<TDto> dtos = Assembler.DomainToService(domainEntities); return new List<TDto>(dtos);
After:
return Repository
.Find(criteria)
.ToList()
.ConvertAll<TDto>(Assembler.DomainToService);
Thoughts? Samples? WTF’s?
return Repository.Find(criteria).Select(Assembler.DomainToService).ToList();
Even easier 😉
Ah yes, very nice!