2
|
PagedList requires an
IQueryable<MyQuery> . Your query object is of type IQueryable<anonymous-type> . To get an IQueryable<MyQuery> you need to change your select to:
You do not need .ToList() to turn this into an IQueryable, it already is.
However, if you do want to execute and cache the IQueriable before passing it to the function, you could do
In most cases this is not what you want. The PagedList requires an IQueryable most likely because it will only retrieve the part of the data that is currently needed for a particular page, leaving the rest of the potentially huge dataset behind the query in the database.
But if you actually want to retrieve all the data only once, and then later turn it into a PagedList, this is the way to go. You can then also reuse the cachedQuery in other places, without causing another database retrieval.
|
Sunday, 2 July 2017
Error converting LINQ anonymous type to IList<>
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2017
(142)
-
▼
July
(13)
- ASP.NET MVC 5 Security And Creating User Role
- ASP.NET MVC - How to hide or Show a link/button ba...
- If statement and Html.ActionLink in Razor MVC 3
- The Role Manager feature has not been enabled
- How to pass HttpContext.Current to function?
- Problems with SQL Server Express user instancing a...
- Group by in LINQ
- how can i get the count in linq
- Using more than one condition in linq's where method
- How does one eliminate duplicates rows from a table?
- Error converting LINQ anonymous type to IList<>
- Check if Record Exists in Entity Framework
- Cloud Print
-
▼
July
(13)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.