views:

115

answers:

1

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?

A: 

AutoMapper does not support mapping to/from expressions or delegates. If you tried to write that mapping by hand, I think you'd see why :)

Jimmy Bogard
Yeah I saw it, unfortunately ... :-)Thanks anyway