Sunday, February 05, 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.
When i run this sample the i have this error: Exception in dataAdapter.Update: Doppelte Zielangabe in 'IDDevice'. What I can do to make the Sample running?
static void Main(string[] args) { PersistenceManager pm = new PersistenceManager(); pm.BuildDatabase(); SnmpDevice dev = new SnmpDevice(); SnmpDevice sdev = new SnmpDevice(); pm.MakePersistent(dev); // pm.MakePersistent(sdev); dev.AddDevice(sdev); pm.Save(); NDOQuery q = new NDOQuery(pm); List result = q.Execute(); }
static void Main(string[] args) { PersistenceManager pm = new PersistenceManager();
pm.BuildDatabase();
SnmpDevice dev = new SnmpDevice(); SnmpDevice sdev = new SnmpDevice(); pm.MakePersistent(dev); // pm.MakePersistent(sdev);
dev.AddDevice(sdev); pm.Save(); NDOQuery q = new NDOQuery(pm); List result = q.Execute(); }
[NDOPersistent] public class Device { string name; [NDORelation(RelationInfo.Composite)] List devices = new List(); public List Devices { get { return new NDOReadOnlyGenericList(devices); } set { devices = (List)value; } } public void AddDevice(Device d) { devices.Add(d); } public void RemoveDevice(Device d) { if (devices.Contains(d)) devices.Remove(d); } } [NDOPersistent] public class SnmpDevice : Device { }
Hi Falk,
NDO generates foreign key column names with the simple algorithm
"ID" + TargetTableName + RelationName.
Thus, if a polymorphic type has a relation to itself, NDO generates a mapping table with two foreign keys having the same name. To work around this behavior, do the following:
1. Delete the NDOMapping.xml in each project of your solution, which is dependent from your BusinessClasses assembly. Leave only the NDOMapping.xml of your BusinessClasses assembly.2. In your BusinessClasses project open the NDOMapping.xml with a doubleclick in the Solution Explorer. Search the entry for the SnmpDevice class and delete it. NDO will regenerate this entry using the settings you'll do with Device in the next step. Save the NDOMapping.xml and close it.3. Open the NDOMapping.xml in the graphical mapping tool. Search for the class Device and open it's Subtree. Click at the "devices" relation and change the ForeignKeyColumnName to "IDParent" and the ForeignKeyTypeColumnName to "TCParent". Click at the MappingTable entry below the "devices" relation. Change the ChildForeignKeyColumnName to "IDChild" and the ChildForeignKeyTypeColumnName to "TCChild".4. Recompile.
NDO regenerates the mapping entry for the SnmpDevice class and copies the mapping file with the new settings to the other projects having a reference to your BusinessClasses assembly.
Best Regards:Mirko