.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
Post a Comment