Linq2SQL + Anonymous Types

Nate Bross

Contributor
Joined
Apr 6, 2005
Messages
601
Location
Chicago, IL
So I have a Linq2SQL type that is the return type for a method.

This works fine; except the lazy loading is causing me issues since I'm returning the method via WCF.

I have been able to use DataLoadOptions to get the related data I need; however it generates some HORRIBLY inefficent SQL, especially since I'm trying to filter 2M records down to about 20. It takes over 15 minutes for this query to execute.

So I'm trying to manually select the data and populate my own instance of a Linq2SQL type. I run into this error: "Cannot convert IQueryable<T> to EntitySet<T>."

I started trying to use an anonymous type, but alas I cannot convert from my anonymous type back into my Linq2SQL type.

Am I screwed? is there away to convert between Anonymous Types / And or IQueryable<T> to EntitySet<T>? or do I need to create my own classes that reflect my Linq2SQL classes?

Any help is appreciated; I can post relevant code if it'd be helpful.
 
Back
Top