Search   

Sunday, February 05, 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  Relations...
 Relations
 
 1/19/2007 10:05:30 AM
FalkW
6 posts


Relations
 Modified By Mirko  on 1/23/2007 11:25:32 AM)

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();
}

[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 { }

 1/23/2007 11:51:08 AM
Mirko
109 posts
5th


Re: Relations

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

  NDO-Forum postings in english please, if possible.  Developing with NDO  Relations...
  SearchSearch  Forum HomeForum Home