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  n:m relationshi...
 n:m relationships
 
 6/8/2007 8:01:28 AM
Siclone
1 posts


n:m relationships

I have a question in relation to Relations.  I apologise if my description of the problem is unclear, but here goes.

I have created a class that defines a list that holds references to objects of itself.  Example:

A Profile object (based on the Profile class as defined below) is intended to hold a list of other Profiles (referred to in the code as subProfiles).  A Profile can exist on its own, without any subProfiles, or it can exist as a subprofile to 1 or more other Profile objects.  For example, I have 4 x Profile objects P1, P2, P3 and P4.  P1, has P2 and P3 as subprofiles whilst P4 has P3 as a subprofile.

Everything with NDO seems to work as per the manual and I create the database, execute my test code which creates the 4 x Profile objects, makes them persistent and then adds them (as subProfiles) to their respective parent Profile objects.  The problem that exists is that a Profile object can only be related to 1 other Profile object, Ie: P3 can only be related to P4, or P1 and not both.

I have created other n:m relationships that use a Composite relationship in the middle, but none as per my description above.  Hopefully I am not doing something obviously incorrect!

The NDO created SQL code to generate the Profile table is included below.

I'd appreciate any pointers or help.  cheers

BTW: The tutorial zip file on your site appears to be corrupt after downloading. FYI

 

/// <summary>
/// Summary for Profile\
/// </summary>

[NDOPersistent]
public class Profile
{

string name;

[NDORelation(typeof(Profile))]
ArrayList subProfiles = new ArrayList();
public IList SubProfiles
{
  get { return ArrayList.ReadOnly(subProfiles); }
  set { subProfiles = (ArrayList)value; }
}

public void AddProfile(Profile p)
{
   subProfiles.Add(p);
}

public void RemoveProfile(Profile p)
{
if (subProfiles.Contains(p))
subProfiles.Remove(p);


}

.....

 

 

CREATE TABLE [Profile](

[ID] Int IDENTITY (1, 1) NOT NULL,

[Name] NVarChar(255) NULL,

[IDProfile] Int NULL,

CONSTRAINT [PK_Profile] PRIMARY KEY ([ID])

);

 6/11/2007 3:00:10 PM
Mirko
109 posts
5th


Re: n:m relationships
 Modified By Mirko  on 6/11/2007 3:05:35 PM)

Hi Siclone,

I posted an answer here, which was wrong. I'll investigate in your question and come back soon to you.

Best Regards:
Mirko

  NDO-Forum postings in english please, if possible.  Developing with NDO  n:m relationshi...
  SearchSearch  Forum HomeForum Home