Link to home
Start Free TrialLog in
Avatar of mikha
mikhaFlag for United States of America

asked on

updating order of the rows, N+1 query issue, C#, asp.net, MVC, SQL Server

I have a sql table like shown below. on the client side with Jquery, user can drag and drop rows in the table, to change the order of rows. on each row reorder event, i want to make a ajax call to update the order in the sql database. I have the id of the row that was moved, its old position and and new position. also i have the id, old and new position of the row that was moved because of the first row that took place of this one.
what would be a best way to determine, for what rows the order column needs to be updated in the database. Also,  to update oder column for each row, i will need to run an update query in an for each loop. is there a better way of doing this?

Table Example{
id int,
name,
order int
}
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

At one time the user will move one row correct?
Avatar of mikha

ASKER

for now, yes.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial