Friday, February 10, 2012
Support » Support Forum
Register Login
HomeWhat is NDO?- Executive Overview- NDO for DevelopersHow NDO Works- Persistent Classes- Mapping- Queries- Reverse Engineering- Inheritance, Polymorphism- Distributed ApplicationsLicensingSupport- Support Forum- FAQ- Solutions- Downloads- E-Mail Support- Tutorial VideosOnline ShopContact
Welcome to the NDO support forum!
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. 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. The forum software requires that javascript is enabled. Please do not insert licence information or licence keys in forum posts. If you know a good answer to a post of another user, feel free to reply! The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.
Private Sub m_oPM_IdGenerationEvent(ByVal t As System.Type, ByVal oid As NDO.ObjectId) Handles m_oPM.IdGenerationEvent
Dim key As New NDO.Int32Key(GetType(Integer), nNextKey) oid = New NDO.ObjectId(key)
Hi Stefan,
use the following line:
CType
Hope, that helps.
Regards:Mirko
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
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