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
|
I've got EntityA which contains ValueObjectB (called Blah). There is a many-1 assoc between EntityA and EntityB. The foreign key in EntityA is ValueObjectB.PropertyA I've set the assoc KeyPropertyRef to "ValueObjectB.PropertyA" but I'm getting messages from the designer sync to delete PropertyA from EntityA. How do i set the designer to recognise the foreign key property? sending a screenshot via email... thanks |
|
|
It seems to be working for me. Are you on a recent nightly? Build 17026 (13 May) fixed a bug with value object database sync in the presence of column name mappings, though I don't know if this is your problem. If you still see the issue on the latest nightly, it means I'm doing something different to you, so please provide a minimal repro and I'll take a look. Thanks! |
|
|
Hmm, actually, I have found a problem, but it's not the one you're reporting. But checking the docs I don't think we support this anyway. Key Property Reference maps to ForeignKeyFieldAttribute, which says: fieldName may be a dotted path into a value object. At present, only dotted paths into a composite So it looks like we currently don't support Key Property References into a separate value object, only into a composite Id. I'll double check this and add a validation warning. |
|
|
i'm using the nightly build from 16th May. *phew* sounds like my approach is right (use of keypropertyref) - ? so i'll see if the model blows up first (just doing that now) and then worry about the message appearing in the designer. assuming the model doesn't blow up then i'll put getting the sync message to disappear on the backburner. otherwise i'll get back to you pronto. thanks |
|
|
Huh, apparently there already is a validation warning (see attached). Maybe I need to upgrade it to an error. And improve the message. |
|
|
oh. i was ignoring that warning along with the other 10 warnings (that nonetheless don't cause runtime errors) because i'm bending STI a bit beyond what's advisable. my screenshot should hopefully show what i'm trying to achieve - and is that possible? |
|
|
It's not easily possible. At present, the foreign key for an association can only be: * The implicitly generated XxxId field * A property directly on the entity * A column within the Id, if the entity has a composite key You would probably be able to do it with a custom association resolver, but that incurs some significant limitations around things like eager loading and cascade deletion. Given that your association appears to be a lookup, and not something you'll need to modify, that may not be an issue. On the other hand, given that it is a lookup, you don't need the tracking capability of a true association. So you could also just omit the designer association and implement a GetStatusInfo() method on the entity with the value object, which would just do return this.UnitOfWork.FindById<StatusInfo>(this.ValueObject.PropertyA). |
|
|
and the winner is... the option given in the last paragraph. thank you very much.
|
|
|
Out of interest, what warnings are you getting? If it seems to be working for you at runtime, then maybe I can refine the designer checks. |
|