简体   繁体   中英

Process query in ADO.NET

I want to convert the result returned by data reader to objects. When I query the data and group it by some field, I find that I am not taking advantage of the ordered data when I try to convert it to a list of objects which each object being the set of rows matching a group by relationship. Using linq might help, but I find it is like regrouping the data and not taking advantage that the query result is already ordered. Does anyone has any suggestion?

If the grouping must be done after the data has been returned from the SQL query (eg because the grouping is dynamic) then you should remove the order by from the SQL query and move it to the Linq instead. Otherwise, do the grouping in the SQL query along with the ordering. The point is, both operations should be done in the same place at the same time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM