I'm stuck on trying to update a group of rows, with a coulmn value +1.
I'm running a sortorder, and moving a row up in the order.
sample table.
id | name | sortorder
1 | mom | 0
2 | dad | 1
3 | child1 | 2
4 | child2 | 3
5 | child3 | 4
moving child2 up the list, so it's sort is 1, i'd have to move dad, and child1 sortorder to plus 1.
The sql would be
update dbo.table set sortorder = sortorder+1 where
id=@id
sortorder >= @newSortOrder and <@OriginalSortOrder
[Param Values]
@id=4
@newSortOrder = 1
@OriginalSortOrder = 3
In LLBLGen I got this far. This is for an insert, so it only needs
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(PredicateFactory.CompareValue(DirectoryFieldIndex.SortOrder, ComparisonOperator.GreaterEqual, dir.SortOrder));
filter.PredicateExpression.Add(PredicateFactory.CompareValue(DirectoryFieldIndex.SortOrder, ComparisonOperator.LesserThan, NewNodeIndex));
So I have the ability to get all the rows that I want to update, I'm just not sure how to set the +1 property.
A friend of mine said that I can update all the siblings in code, and then run an Adapter.SaveEntityCollection(), and I agree that that would work.
But it just doesn't feel right. If I have 1000 siblings, then that is going to generate alot more sql then it needs to.
Thanks for the advice