This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Normal 0 false false false EN-NZ X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} Hi,
I’m trying to write a LS query that returns an IQueryable for the purpose of paging.
I’ve got a parent object (Folder), which contains many child objects (RecordSets), each of which contain many child objects (Records). What I need is to pass in a folder entity and retrieve its records as an IQueryable for the purpose of paging. Sort of like this; public IPagedList<Record> GetFolderRecords(Folder folder, int pageSize, int pageIndex) { List<Record> records = folder.Records.PageAt(pageSize, pageIndex); int totalCount = folder.Records.Count(); return new PagedList<Record>(records, totalCount); }
It’s very similar to the sample LS queries except I’m querying for grandchildren of the folder, not just children.
I see from the LS documentation that the LINQ to LS doesn’t support joins which is what I think I’m needing here. But what would be the next best equivalent? I’m not that keen to be getting all the recordsets for the folder back and querying from there because it won’t scale. So should I just sproc this or is there a clean LS way? cheers justin |
|
|
Hi Justin,
Although we don’t support joins in the general case, we do have support for the specific pattern of matching against a field in an indirectly associated entity, and you can then put paging modifiers on that in the normal way. The LINQ version would look like this: var
query = (from r in
UnitOfWork.Records This will execute the query within the database and retrieve only the records required for this page. |
|
|
ok,that works fine thanks. but... as per thread http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=1515, i need to be able to order the results (from the above query) by a property such as Record.Classification.Name. This seems a fairly common requirement, especially with paging etc on websites. Have you got a timeframe for when this will be supported by the LS querying engine? I don't particularly like either of the workarounds and as timcope says, this would be an important (and typical) feature for any application. cheers |
|
|
Hi Justin, We're not particularly fond of the workarounds either and have scheduled to look into enhancing the querying engine for what you need over the next couple of weeks. We'll keep you posted. Hope that helps, John-Daniel |
|