Search   

Friday, February 10, 2012

Support » Support Forum

Register  Login

 Menu  
 
    

 Welcome!  
 


Welcome to the NDO support forum!

kreis.gif Please register/login at the site if you want to post a thread. We sometimes copy support mails of common interest to the forum. They appear with anonymous sender.
kreis.gif Please post your messages in English language if possible. You can do your posts also in German, we will translate your post and our answer so that all users of the forum can read your posts.
kreis.gif The forum software requires that javascript is enabled.
kreis.gif Please do not insert licence information or licence keys in forum posts.
kreis.gif If you know a good answer to a post of another user, feel free to reply!
kreis.gif The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.

   Print   

      
 NDO Support Forum  
 
SearchForum Home
  NDO-Forum postings in english please, if possible.  Developing with NDO  Generation of m...
 Generation of my own DB Keys
 
 6/14/2006 3:52:21 PM
stm
3 posts


Generation of my own DB Keys
Hi I'm trying to generate my own DB keys and therefore have installed a handler Private Sub m_oPM_IdGenerationEvent(ByVal t As System.Type, ByVal oid As NDO.ObjectId) Handles m_oPM.IdGenerationEvent
Now I've tried to tell NDO my generated ID:
Dim key As New NDO.Int32Key(GetType(Integer), nNextKey) oid = New NDO.ObjectId(key)
This does not work.
How to do it correctly?
Stefan
 6/19/2006 2:13:36 PM
Mirko
109 posts
5th


Re: Generation of my own DB Keys
 Modified By Mirko  on 6/19/2006 2:14:00 PM)

Hi Stefan,

use the following line:

CType(oid.Id, Int32Key).Key = intKeyValue

Hope, that helps.

Regards:
Mirko

 7/25/2006 10:18:00 PM
Gerhard
12 posts


Re: Generation of my own DB Keys
 Modified By Mirko  on 7/26/2006 7:03:48 PM)

Hi Mirko, as you know, I have problems with server generated IDs. Therefore I decided to change the code for client generated IDs, but without success. Here is what I did:

class CPersistenceManager
{
    internal CPersistenceManager(string sDatabasePathAndName)
    { 
      m_PM = new PersistenceManager(); m_PM.IdGenerationEvent
      += new IdGenerationHandler(PM_IdGenerationEvent);
    }
    void PM_IdGenerationEvent(Type t, ObjectId oid) 
    { 
      NDO.Int32Key MyKey = new Int32Key(typeof(System.Int32), 
      CPersistenceManager.Key++); 
      oid = new ObjectId(MyKey);
    } 
    static private int Key = 1;
}

For all DB classes I extended the attribute [NDOPersistent, NDOOidType(typeof(System.Int32))]. The event is called, but the first data row is inserted with ID=0 (for all DB classes) and and for the next insert I get an error. Regards Gerhard

 7/26/2006 7:07:48 PM
Mirko
109 posts
5th


Re: Generation of my own DB Keys

Hi Gerhard,

the solution ist in my last answer . Don't change the oid value, but do the following:

void PM_IdGenerationEvent(Type t, ObjectId oid) 

    CType(oid.Id, Int32Key).Key = CPersistenceManager.Key++; 

That should do it.

Best Regards,
Mirko

 7/27/2006 8:59:56 AM
Gerhard
12 posts


Re: Generation of my own DB Keys
Hi Mirko, I have seen you answer, but this is not clear for me. I couldn't find anything about CType (not in C# and also not in NDO documenation). So your new suggestion doesn't help me. Regards Gerhard
  NDO-Forum postings in english please, if possible.  Developing with NDO  Generation of m...
  SearchSearch  Forum HomeForum Home