Question

I'm trying to create a custom mapping with AutoMapper, but I can't use 3.0 syntax with lambdas. How would one convert this 3.0 code into 2.0 ?

Mapper.CreateMap<MyClass, MyDto>()
 .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.CompanyName))

Edit:

Since there was no better solution, we are now using vs2008 on one workstation to make these mappings and build a dll. I hope it won't be long until we upgrade to vs2010.

Was it helpful?

Solution

EDIT: Jimmy has mentioned in the comments that AutoMapper uses expression trees. That doesn't immediately rule out the possibility of using .NET 2.0 (you can use Mono's implementation of System.Core), but if you can't even using C# 3 you'll have to construct all the expression trees manually, which it going to be a huge pain.

Are you absolutely prohibited from using .NET 3.5 and C# 3?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top