Inject From EF query

Sep 4, 2013 at 9:33 AM
Edited Sep 4, 2013 at 9:33 AM
I have a EF query for example :
var q = from a in db.Persons select a;
I want a list of PersonViewModel

This code :
var q = from a in db.Persons
            select new PersonViewModel().InjectFrom(a);
don't work, it give "LINQ 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."
Coordinator
Sep 4, 2013 at 4:48 PM
call ToArray or ToList before InjectFrom to evaluate the sql