0

I know that L2S is not designed to map custom/POCO types to L2S-entity types without the object initializer syntax. But is there a back-book way to achieve this so that i can project into my POCO with a parameterized constructor and not get stung when i try to apply an expression to that result?

Community
  • 1
  • 1
Matt Kocaj
  • 11,278
  • 6
  • 51
  • 79

2 Answers2

0

Do a ToList() into memory and run your statements against in-memory collection.

Yes of course its not as effecient as querying against L2S IQueryable. But the design is cleaner.

I been down that road before. It turned out badly. L2S and EF implementation of IQueryable just does not work (well) with anything other than the object it was designed for.

Sleeper Smith
  • 3,212
  • 4
  • 28
  • 39
  • Thanks for the answer but this is not a solution for me. I need to have L2S generate SQL- I can't have the filtering happening in memory. I'd be dragging gigs of data into my app. That's not going to happen. What you may have highlighted is that L2S may not meet my needs. Thanks again. – Matt Kocaj May 23 '11 at 01:39
  • You may want to have a look at EF code first. It uses POCO and POCO datacontext class too. Not that EF codefirst work well with interfaces either, but it's a lot better. – Sleeper Smith Jun 04 '11 at 08:22
  • as for "not get stung when i try to apply an expression to that result" that's still no go in EF code first either (afaik) – Sleeper Smith Jun 04 '11 at 08:23
  • Thanks. I'm leaning towards Fluent NHibernate atm. We'll see how that goes for my requirements. – Matt Kocaj Jun 07 '11 at 07:22
0

You can't.

And if there is a "back-book way" I haven't found it (and I suspect I don't want to).

Matt Kocaj
  • 11,278
  • 6
  • 51
  • 79