Fix segment writes

Query criteria was inconsistent with dbo being saved, since the type of the ID in the query is a string, yet in the dbo it is a long.