31 Mar
2008

How have the new features of C# changed your code?

Category:UncategorizedTag: , , :

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?

2 thoughts on “How have the new features of C# changed your code?

  1. return Repository.Find(criteria).Select(Assembler.DomainToService).ToList();

    Even easier 😉

Comments are closed.