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
|
Hi, I have encountered a little problem over using lightspeed's linq query. My linq statement is quite simple one. I was trying to sort the table by timestamp then group the file by filegroup and then take the first 10.
but when I see the executed statement, it doesn't have "order by timestamp" but it has a [order by the "group by key"]. Would there be any other ways to have the same result as the linq query above? or will there be any sort of update to fix this? I have tried this on LightSpeed 5.0 131029 nightly. Regards Daniel |
|
|
Because you are grouping the files the initial ordering is irrelevant. The ordering used on the grouping is just to maintain a natural ordering to the results. Are you wanting to have the lists inside the groups order by TimeStamp? If so use a fg.OrderBy(f -> f.TimeStamp) inside your selection.
|
|
|
Hi Jeremy, Thank you for the reply, but I am wanting to have the list populated in ascending order of timestamp first, then take n number of files from it without having duplicated filegroup. For example,
then assuming I would want to take top 2, the end result of above would look something like this.
Regards Daniel |
|
|
Hi Daniel, It still sounds like you just want to have the resulting list of files order by timestamp so the change above would cover that. But it sounds like I must be missing something if you think that is not the case - to help clarify, what SQL statement would produce the results you need here?
|
|
|
Hi Jeremy, Well, as you can see from the result list from my previous post, it is not possible to do in a single query. However, I see how lightspeed uses two queries to map entities.
The select statement above will produce the first set, which is order by timestamp and showing only distinct filegroup. then the second statement would be something like "select everything that contains FileGroup from the first query." Then we have all the data to map into something like the result from my previous post. I notice that lightspeed already does the similar queries except it looks like we can't alter "order by ..." within "over()" call to what I want. Regards Daniel |
|