> On Thu, Feb 12, 2009 at 9:50 AM, Ayende Rahien <[email protected]> wrote:
>> insert = false, update = false, generate = true.

Could it be this that Ayende is talking about?

Chapter "5.1.9. property"
http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html

generated="never|insert|always"

But it seems that it is not supported by ActiveRecord, or?

On Thu, Feb 12, 2009 at 11:03 PM, Jimmy Shimizu <[email protected]> wrote:
>
> Maybe Generate only exists for PrimaryKey. I think it's better to resort to 
> the DB-engine  for the autoincrement.
>
> On 12 feb 2009, at 22:03, Martin Nilsson wrote:
>
> Where do I put this?
> Can't find the generate property. Is it possible with ActiveRecord or is it 
> only possible with NHibernate?
> I thought it should be something like this:
>
> [Property(Insert = false, Update = false, Generate = true)]
> public int OrderId { get; set; }
>
> But Generate does not exist.
>
> On Thu, Feb 12, 2009 at 9:50 AM, Ayende Rahien <[email protected]> wrote:
>>
>> insert = false, update = false, generate = true.
>>
>> On Thu, Feb 12, 2009 at 10:43 AM, Martin Nilsson <[email protected]> wrote:
>>>
>>> I tried with Formula and update=false but no success
>>> Have to look into Formula a little bit more.
>>>
>>> On Thu, Feb 12, 2009 at 9:27 AM, Jimmy Shimizu <[email protected]> 
>>> wrote:
>>>>
>>>> Wouldn't it be possible to have a
>>>>
>>>> [Field("some_auto_incrementing_field_in_db", Update = false)]
>>>> public int OrderNumber;
>>>>
>>>> perhaps? I'm trying the Update = false thing right now myself, I'll let
>>>> you know if I'm successful :)
>>>>
>>>>
>>>> Martin Nilsson wrote:
>>>> > Number 1, is that possible with AR? I can't have it as a primary key
>>>> > but as a normal property. Tried a little bit with the Formula
>>>> > parameter for PropertyAttribute but didn't had any progress there either.
>>>> >
>>>> > [ActiveRecord]
>>>> > public class Order
>>>> > {
>>>> >   [PrimaryKey(PrimaryKeyType.GuidComb)]
>>>> >   public Guid Id {get; set;}
>>>> >
>>>> >   [Property(??)]
>>>> >   public int OrderNumber {get; set;}
>>>> > }
>>>> >
>>>> > On Wed, Feb 11, 2009 at 3:29 PM, Ken Egozi <[email protected]
>>>> > <mailto:[email protected]>> wrote:
>>>> >
>>>> >     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] <mailto:[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
-~----------~----~----~----~------~----~------~--~---

Reply via email to