off the top of my head: 1. you can set it as a readonly property, and have the DB initiate the value (in SQL server use IDENTITY(1000, 1) ). I think you'd need to set the field as int? so it won't try to save 0 to the DB 2. call the DB when inserting to get the highest OrderNumber and plus 1 it 3. If you know for sure that only the application can access the DB, you might consider setting a variable with the last OrderNumber, increasing it when needed with an appropriate logging mechanism.
On Wed, Feb 11, 2009 at 4:15 PM, Martin Nilsson <[email protected]> wrote: > How do I best setup my active record class to have a natural key. Instead > of guid as order number I want a sequence that starts with 10000 for > example. > > [ActiveRecord] > public class Order > { > [PrimaryKey(PrimaryKeyType.GuidComb)] > public Guid Id {get; set;} > > [??] > public int OrderNumber {get; set;} > } > > Note that I will still have guid as id to keep track of if it is saved or > not but I want to show the customer a more friendly order number. > > > > -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
