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.
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])
);
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