Up Create, modify and delete code samples

Code sample: NumericIdGenerator

Last modified on September 20, 2012 11:10

This shows a sample implementation of a custom id generator for numeric data types.


Problem

You have to write a custom id generator when a new entity's permanent key must be calculated with information only accessible on the EntityServer.  The key is not generated by the database (store-generated) nor can it be assigned in creation code on the client.

Solution

You can implement an IIdGenerator to handle custom id generation.  This sample NumericIdGenerator can be used as is or adapted for use in your application.  The sample will handle numeric data types:  first assigning a negative temporary id and then assigning a real id using a NextId database table.

Prerequisites

If you use the NumericIdGenerator as is you will need a NextId database table.  The script to create this table is in the download.

Created by DevForce on May 09, 2011 10:10

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2020 IdeaBlade