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
|
We are using a slightly denormalised database structure for part of our application and having afew issues around having 2 fk's linking from one table to another. We are getting the following exception through one of our tests Mindscape.LightSpeed.LightSpeedException: Could not determine the reverse association of [UserGoal.SubCategoryGoal (Goal)]
Code is as follows (just a basic example): public class UserGoal: EntityBase #region members private int? _subCategoryGoalId;
public int GoalId public Goal SubCategoryGoal public int? SubCategoryGoalId }
#region members private readonly EntityCollection<UserGoal> _userGoals = new EntityCollection<UserGoal>(); #endregion #region properties public EntityCollection<UserGoal> UserSubGoals #endregion }
So i'm not 100% sure how the reverse relationship is picked up, is it based of naming conventions? if so, what convention should we be using?
Help much appreciated. Matt |
|
|
Hi Matt,
Yeah, it's to do with how LightSpeed "guesses" reverse associations. I'm working on a more robust strategy at the moment and will get back to you this morning.
Cheers,
Andrew.
|
|
|
Haha - funnily enough I have run into a similar sought of issue at the same time :-) I have an A with many B's - B has the reverse association to A but also has another reverse association in the form of A' and A''. I have it working but have had to step through a few issues to get there i.e. I had to name the collection of B's a certain way to get it to map to the right column etc - this caused the naming to not make sense in the class it was declared in but did make it work... (I have also noticed that nulling out A'' would cause it to be deleted from the collection in A... - weird but might be something to just check for as you suss out a fix :-) ) I also had to force the collections to eager load (ok for my case) to get it to all marry up correctly... Is it possible to supply an attribute so we can point it at the right column/entity holder on the reverse association side? Running into limitations/having to name things a funny to get it to work was a bit of a pain (in my case the collection of B's if named correctly would naturally look to map to A' but I wanted it going to A which meant naming it in a fashion which really made no sense) - will be good to see what you come up with :-) Also, would it be possible to supply the rules the mapper uses in the up coming help docs? If you can that would be mint - Cheers, James |
|
|
Hi James, 1.1 will have the attribute you speak of :-) Currently, we use a fuzzy matching algorithm to guess which associations belong to which. Unfortunately it isn't robust enough yet so I'm switching over to the attribute (ReverseAssociationAttribute). n.b. The attribute is only required on one end (either one) of an association when there are more than one association between the same two models. Cheers, Andrew. |
|
|
Awesome! Any details on when 1.1 will be released? :-) |
|
|
Soon :-) I can get you a preview - what edition are you on? A. |
|
|
That would be awesome :-) I'm just running on the personnal/express version at the moment... |
|