I have a table that has a column called Ordinal used to keep track of display order. When an entity changes its ordinal value, the other records in the database need to have their ordinal value adjusted, either up or down depending on the situation. Is there a way through llblgen to do this (2.6 adapter .net 3.5)?

I would need generated queries to be something like these…

```
update MyTable set Ordinal = Ordinal + 1 where Ordinal >= @newOrdinal
update MyTable set Ordinal = Ordinal - 1 where Ordinal <= @newOrdinal and ordinal > @oldOrdinal
update MyTable set Ordinal = Ordinal + 1 where Ordinal >= @newOrdinal and Ordinal < @oldOrdinal
update MyTable set Ordinal = Ordinal - 1 where Ordinal > @oldOrdinal
```

I don't think

```
adapter.UpdateEntitiesDirectly(newValues, filter);
```

will work because newValues is going to be static when I need to add or subtract from the current value of the field

I also know I can achieve this using sprocs or triggers, but I'd like to do it through llblgen if possible.

Thanks,

Jeremy

## Best Solution

Found the answer, expressions in entity updates.

http://www.llblgen.com/documentation/2.6/Using%20the%20generated%20code/gencode_expressionsaggregates.htm#expressionsinentityupdates