.net - Call a DTO translator inside IQueryable's Select -


i have following code query entitycontext (through repository) , map unto dto:

public class queryquestionsconsumer : iconsumerof<queryquestionsrequest> {     public void consume(queryquestionsrequest request)     {         var repo = ioc.resolve<iunitofwork>().createrepository<question>();         var filter = filtertranslator.createfilterexpression<question>(request.filters);         var questions = repo             .getall()             .where(filter)          result = questions.select(question => questiontranslator.todto(question)).toarray()     }  } 

this fail because todto() isn't recognized function in entityframework provider. create dto object using object initializer i'd delegate class (questiontranslator).

what do in case?

updated: additionally, don't want hydrate full question object that. i'd count on provider's ability create dto objects.

besides obvious option of using questions.asenumerable().select(...) force ef retrieve full records , mapping them client side, can make todto method return expression:

expression<func<question, questiondto>> todto() {     expression<func<question, questiondto>> exp =         question => new questiondto { ... };     return exp; } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -