2

LINQ to Entities has many LINQ methods marked as "Unsupported" (http://msdn.microsoft.com/en-us/library/bb738550.aspx).

Is any way to implement some of these methods by hands? Or I should wait next release of EF?

I'm especially needing this method:

IQueryable<TResult> Select<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, int, TResult>> selector)

Thanks

UPD: For example I want to use select in this way:

var usersWithRowNumbers = allUsers.Select((u, index) => new {UserID = u.UserID, Index = index});

1
  • can you give a code blurb on what you would like to do with select? There are work around for almost all ef issues, are you looking to do some type of partitioning? Commented Apr 13, 2010 at 11:45

2 Answers 2

2

LINQ to Entities (and other LINQ implementations based in IQueryable<T>) work by translating expression trees into the target system (in LINQ to Entities: SQL).

To support additional operators, changes would have to be made in that translation layer, which is at the very core of the providers implementation.

Given SQL is set orientated, I doubt any of the query operators which support a delegate or expression tree taking an index will ever be supported.

Sign up to request clarification or add additional context in comments.

Comments

2

Something like that?

allUsers.Select(u => new {UserID = u.UserID}).ToList().Select((u, index) => new {UserID = u.UserID, Index = index})

EDIT

If you want to make additional filtering, make it before executing ToList():

allUsers.Select(u => new {UserID = u.UserID}).AdditionalFilters().ToList().Select((u, index) => new {UserID = u.UserID, Index = index})

If it is not solution then please, be more precise with what you want to achieve. Example with data or sql query would be good.

3 Comments

Yes, something like that. But for LINQ to Entities.
Would AsEnumerable() instead of ToList() be enough to make the second Select possible? If so, it would avoid storing all the IDs in memory at once, in case there are lots of them.
But it isn't Linq to entities. I cannot store all items in memory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.