IQueryable mapping

Mar 17, 2014 at 12:41 PM
Hi

could you please help me with implementation of IQueryable mapping.
I found answer here:
http://stackoverflow.com/questions/16365947/queryableextensions-for-valueinjecter

but I cannot understand how to collect all values from IQueryable collection. It is mentioned that I need to do that with: dto.InjectFrom<SmartInj>(entity), but if we assume that I have entity which is IQueryable and I want to return dto which is also IQueryable, I'm not sure how to do that.
This is my example code:
public virtual IQueryable<TInput> MapCollectionToInput(IQueryable<TEntity> entity)
        {
            //implementation here
        }
Could you please provide a simple example?
Mar 17, 2014 at 12:59 PM
should be something like this:
return entities.Select(o => new TInput().InjectFrom(o)).Cast<TInput>();
Mar 17, 2014 at 1:30 PM
tried but got this error

System.NotSupportedExceptionLINQ to Entities does not recognize the method 'System.Object InjectFrom(System.Object, System.Object[])' method, and this method cannot be translated into a store expression.
Mar 17, 2014 at 3:01 PM
return entities.ToList().Select(o => new TInput().InjectFrom(o)).Cast<TInput>();
Mar 17, 2014 at 3:25 PM
But it will transform IQueryable to List first and load whole collection, correct me if I'm wrong.
Mar 17, 2014 at 3:28 PM
Mar 17, 2014 at 3:33 PM
Is there any chance to implement same functionality as QueryableExtensions from AutoMapper?
Mar 18, 2014 at 1:22 PM
Can you help please.
Everything else work for me except this thing.
I tried to switch to AutoMapper but I faced lots of bugs, and I'm not satisfied.
Mar 18, 2014 at 1:32 PM
use the code mentioned above or use use loop instead
Mar 18, 2014 at 3:07 PM
It will be slow.
Mar 25, 2014 at 9:26 PM