AutoMapper and Linq expression.
Posted
by
Raffaeu
on Stack Overflow
See other posts from Stack Overflow
or by Raffaeu
Published on 2010-03-09T19:30:27Z
Indexed on
2011/02/13
7:25 UTC
Read the original article
Hit count: 241
lambda
|automapper
I am exposing the Dto generated from AutoMapper to my WCF services. I would like to offer something like that from WCF: IList GetPersonByQuery(Expression> predicate); Unfortunately I need back an expression tree of Person as my DAL doesn't know the DTO. I am trying this wihtout success:
var func = new Func<Person, bool>(x => x.FirstName.Contains("John"));
var funcDto = Mapper.Map<Func<Person, bool>, Func<PersonDto, bool>>(func);
Console.WriteLine(func.ToString());
Console.WriteLine(funcDto.ToString());
THe error that I get is:
----> System.ArgumentException : Type 'System.Func`2[TestAutoMapper.PersonDto,System.Boolean]' does not have a default constructor
Do you have any suggestions?
© Stack Overflow or respective owner