We have to work on pagination-subqueries.
You can use:
db.Users.Skip(0).Take(2).AsEnumerable().Select(x=> new UserDto(x.Id,
x.Name));

On Wed, Jun 8, 2011 at 2:44 PM, Darren Kopp <[email protected]> wrote:

> I've been grabbing source off github so I don't have patch with failing
> test, but here's the test source that you can put into the Projections test
> file in linq directory
>
>         [Test]
>         public void CanUseSelectMethod()
>         {
>             var query = db.Users.Skip(0).Take(2).Select(x => new
> UserDto(x.Id, x.Name));
>
>             Assert.IsNotEmpty(query.ToList());
>         }
>
> What does work is this:
>     var query = db.Users.Select(x => new UserDto(x.Id,
> x.Name)).Skip(0).Take(2);
>
> I'm not sure if this is actually a bug (it kind of is for MS sql, not sure
> about others), but a NotSupportedException is thrown if you do paging before
> a projection, everything works fine if paging is done after the projection.
> Makes sense, but can easily be fixed by applying skip/take to whole query,
> where as this i believe would try to page over the entities then build a
> projection off the paged result, which doesn't work in sql server.
>
> So yeah, if it's not a bug, maybe just document it somewhere somehow for
> people to find when googling, threw me through a bit of a loop trying to
> figure out what was going on.
>
> -Darren
>



-- 
Fabio Maulo

Reply via email to