I am trying to solve a problem similar to that described here
Initializing strongly typed objects in LINQ for objects
only from a completely opposite direction . I have a number of functions in my repository, all of which return identical data. The problem is my projection code:
select new pocoClass
{
// complex projection that is several pages long includes grabbing a graph of data
}
at the moment when it exists for each request in the repository. I tried moving it to the object initializer, but it gives me the scary "LINQ to Entities only supports constructors without parameters and initializers." question.
I tried splitting two requests
var candidates = (from thing in _entities.whatever
where (complex.stuff==true)
select thing);
var final = (from thing in candidates.AsEnumerable()
let x = thing.ITEMS.Where(blah=>blah.blah==param)
let y = x.OTHERITEMS.FirstOrDefault()
select new pocoClass(thing,x,y);
final null, pocoClass . let x y , .
, ?