I have a database table with a sortOrder column. I display this list to the user and they use jquery to resort the list, then save it back to the server.
After the reorder the list I get a new list in the correct order of all the IDs in that database table.
I need a good way to update this new sort order to the database. What I want is to query the database with a custom sort order based off this list of IDs I get back from the user. I can then step through that list and increment the sort order from 0.
Bonus points for code in VB, although C# is fine too.
Thanks!
You can’t store the sort order in the database unless you have a sort order field in the datatable (or an association with a sort order table that stores the original table’s field as an FK). If you have this field then in your linq query do,
OrderBy(x=>x.SortOrder)So you have database record projection
When you get the
IQueryable<ObjectFromDb> queryableand theint[] newSortOrder, do this: