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
|
Hi, I am trying to model a circular relationship with LS. The model contains a 'Person' object that contains a one-to-many to an 'Address' object. I understand that for one-to-one relationships I must place a collection on the other end, I have done that in the 'Address' object, but I am still having difficulties. I have also decorated the collection ends with ReverseAssociation attributes. Specifically, I am getting stack overflow exceptions on the Visit Method of the TopologicalSort class. What is the best way to model this type of structure using LS. I'm probably just missing something obvious :). Thanks in advance, Kavan |
|
|
What about something like: table Address Then in Person you can create vanilla .NET properties for HomeAddress etc. that do a collection look-up. Cheers, Andrew. |
|
|
Hi Andrew, I thought of using Non-Persisten properties, however, this is a port of a living app. And the current address objects do not specify type (i.e. no enum for home, work, etc.) The address type was being specified by holding a ref. Why is it not possible to support a persistent one-way ref with no collection on the other end. It does have it's uses (or at least it would make porting existing logic a bit easier Thanks again, Kavan |
|
|
Hi Kavan, // Contribution.cs private int? _approvedById; public int? ApprovedById [ReverseAssociation("ApprovedContributions")] public Member ApprovedBy private int _contributorId; public int ContributorId // Member.cs private readonly EntityCollection<Contribution> _approvedContributions public EntityCollection<Contribution> ApprovedContributions public EntityCollection<Contribution> Contributions Cheers, Andrew.
|
|
|
Hi Kavan, I forgot to add that a another really good way of doing this is to use the Value Object pattern via ValueObjectAttribute. Cheers, Andrew. |
|
|
Hi Andrew, The problem I'm having is thatmy model has both a EntityCollection and EntityHolder on each side. To replicate it in your sample domain, add an EntityHolder<Contribution> in the 'Member' class and the necessary EntityCollection in the 'Contribution' class. You then should see the StackOverflowException I am receiving. Thanks, Kavan |
|
|
[quote user="andrew"] Hi Kavan, I forgot to add that a another really good way of doing this is to use the Value Object pattern via ValueObjectAttribute. Cheers, Andrew. [/quote] Hi Andrew, If I turn the addresses into ValueObjects then I loose the ability to reference. Because in this use case the address collection also holds inactive addresses and the such. It may also be possible to have more than one work, home, etc. address (with one of course being primary for each type). I am definetly open to modeling this in a more straightforward manner. In the meantime, I will continue to store each types reference Id field. And then manually lookup from the collection the proper address. Eager loading makes bring the addresses efficently a snap. Many thanks, Kavan |
|
|
Hi, Any progress on implementing one-way references (i.e references not requiring a collection on the other end). The reason I'm bugging about this feature is in the port I'm currently doing it is a very heavly used pattern. As always, Thank you, Kavan
|
|
|
Hi Kavan, We're about to schedule this feature. Could you provide some more detail on exactly how you would like this to work? Cheers, Andrew. |
|
|
Hi Andrew, In a nutshell, I would just like to be able to have the reference on one-side of the relationship. In psuedo-code it would like: class Order Guid _SupplierId; } class Supplier <No Collection back to Order> Obviously this type of relationship would not need to cascade deletes. Hope that helps. Thanks again, Kavan
|
|