2010-03-09 62 views
1

我将从AutoMapper生成的Dto公开给我的WCF服务。 我想提供类似于WCF的文章: IList GetPersonByQuery(Expression> predicate); 不幸的是我需要返回Person的表达式树,因为我的DAL不知道DTO。 我想这wihtout成功:AutoMapper和Linq表达式

 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()); 

的错误,我得到的是:

----> System.ArgumentException : Type 'System.Func`2[TestAutoMapper.PersonDto,System.Boolean]' does not have a default constructor 

你有什么建议吗?

回答

0

AutoMapper不支持映射到/从表达式或委托。如果你试图手写这个映射,我想你会明白为什么:)

+0

是的,我看到它,不幸... :-) 无论如何 – Raffaeu 2010-03-10 12:14:37