This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, I am using Lightspeed Professional with VS2008 targetting .NET 2.0 and have come across a weird thing in our existing data structures. We use MySql5 and Sqlite. In the Sqlite dialect, I have a table defined similar to: CREATE TABLE [Person] ([Id] integer PRIMARY KEY NOT NULL, [MotherId] integer NOT NULL, [FatherId] integer NOT NULL, CONSTRAINT [FK_Person_MotherId_Person_Id] FOREIGN KEY ([MotherId]) REFERENCES [Person] ([Id]), CONSTRAINT [FK_Person_FatherId_Person_Id] FOREIGN KEY ([FatherId]) REFERENCES [Person] ([Id]) ); Dragging this table to the Lightspeed dsmodel creates it okay and the self-referencing parts are both built. However, the dsmodel will not compile due to an error of Entity Person has multiple properties/associations named 'People' Which actually perfect sense.... all things considered :) The generated code is: along with the associated properties. I can surely change the generated code but I'm wondering if there is something better I could do? I could change the table definition within our application if that'd be better but that'd be way more work :) Any suggestions or comments welcome. Thank you to all! Regards, Lionel |
|
|
Hello Lionel, Sorry for the delay in replying -- holidays... This will be difficult to model in the ideal way using LightSpeed because LightSpeed always wants to see a reverse association: that is, for the many-to-one Mother association there must be a corresponding one-to-many association (PeopleForWhomIAmTheMother), and for the many-to-one Father association there must be another corresponding one-to-many association (PeopleForWhomIAmTheFather). Whereas you presumably want a single Children collection. If you are willing to stomach the two collections (or if two collections is in fact appropriate to your use case), then the solution is just to rename them in the designer -- you can do this by selecting the association and editing the Collection Name in the Properties window. If you want a single Children collection, which would contain all entities for which the selected entity is the mother *or* the father, then I am afraid LightSpeed can't currently do this. The reason for this behaviour is automatic wireup. Suppose there were a single Children collection, and you went evelyn.Children.Add(alice). LightSpeed would want to set one of set alice's MotherId or FatherId properties to evelyn's Id, but it would have no way of knowing which one. |
|
|
Hi Ivan- Thank you for replying, I appreciate your time. I do need the table to be defined with the two collections (Mothers and Fathers) - each Person needs to know who its Mother and who its Father is in my use case. Specifically there is only 1 Mother and 1 Father but Lightspeed isn't responsible for my restrictions there. I have done what you said by renaming the 2 generated collections from 'People' to 'Mothers' and 'Fathers'. Lightspeed seems to be resolving everything okay in my tests on this table. I'll just remember to rename them should I ever recreate the model for this table. As an aside, and I can't believe I missed this in my initial post, but it just occurred to me that Lightspeed model generation named the collections 'People'... I guess, in my hardwired brain, I was expecting it to be 'Persons'... it is the 'Person' table, after all :) Thank you Ivan, I appreciate your time! Regards,
|
|