|
|
How to design this relationship in AppArchitect?
Posted: 26 Feb 08 5:58 AM
|
I'm trying to re-create a LAN tab in 7.2 web. The contact-level tab shows other contacts at the account of this contact; a sort of 'sibling' relationship if you consider the contact to be a child of an account.
So I'm trying to make AppArchitect understand I want a grid which shows contact data where the accountID of those contacts = the accountID of the current contact. How do I design this relationship? Or is there a much simpler way of achieving this?
Thanks in advance for any help you can offer.
- Alec D, QGate |
|
|
|
Re: How to design this relationship in AppArchitect?
Posted: 26 Feb 08 6:31 AM
|
Alec, the Relationship should already exist since the contacts are children of the Account.
Your contact instance has a reference to an Account entity. That Account entity would already have a property on it called Contacts (ICollection). This would be a List of contacts owned by the account. you could add a custom property the the contact to return the relationship with the current contact filtered out.
namespace Sage.BusinessRules.CodeSnippets { public static partial class ContactBusinessRules { public static void GetContactSiblingsStep1( IContact contact, out ICollection<IContact> result) { EntitySet<IContact> contacts = new EntitySet<IContact>(); foreach (IContact currCont in contact.Account.Contacts) { if (contact.Id != currCont.Id) contacts.Add(currContact); } return contacts; } } }
Code is untested but I hope it leads you in the right direction.
Regards, Mark
Mark |
|
|
| |
| |
| |
|
Re: How to design this relationship in AppArchitect?
Posted: 03 Mar 08 10:41 AM
|
Originally posted by Mark Dykun
EntitySet is a 7.2.2 thing Gene. Sorry for not clarifying. |
|
Hi Mark,
Have you looked into what benefits there are in using EntitySet vs a standard IList? I've noticed that many OOTB business rules still return an IList. EntitySet inherits from AbstractEntityCollection (which implements ICollection & IEnumerable). It does appear to have some extra stuff in it, but couldn't see any clear cut reason to use it instead of an IList.
Have you seen anything that would show benefits using one vs. the other?
-Ryan |
|
|
|
Re: How to design this relationship in AppArchitect?
Posted: 03 Mar 08 10:48 AM
|
Honestly I have not dug that deep into it. I noticed when looking at how the new business rule was supplied for getting the Account contacts was using this approach, I was assuming this was going to be the new standard moving forward. I understand that you are returning an IList but specifically what concrete type. Since IList is an interface there needs to be a creatable class type to add these entities to. Are your returning a List<Entity> .
Mark |
|
|
| |
| |
|
Re: How to design this relationship in AppArchitect?
Posted: 11 Mar 08 6:44 AM
|
If you can please post your code for the business rule so that I can determine what is happening. Gennerally it looks as if thw System.Collections - or - System.Collections.Generic namespace is not mapped into the class however you may be using the wrong type of collection for what you are trying to do so seeing the code will help with this determination. |
|
|
|