KastroNYC wrote:
Sorry about that, it is an M:N through ContactInformation Telephone.
THis is a major difference.
I've tried:
IPrefetchPath path = new PrefetchPath((int)EntityType.CompanyOfficeEntity);
path.Add(CompanyOfficeEntity.PrefetchPathContactInformation).SubPath.Add( ContactInformationEntity.PrefetchPathContactInformationTelephone)
.SubPath.Add(ContactInformationTelephoneEntity.PrefetchPathTelephone);
then binding with
Eval("TelephoneCollection")
and
IPrefetchPath path = new PrefetchPath((int)EntityType.CompanyOfficeEntity);
path.Add(CompanyOfficeEntity.PrefetchPathContactInformation).SubPath.Add( ContactInformationEntity.PrefetchPathTelephoneCollectionViaContactInformationTelephone);
and binding
Eval("TelephoneCollectionViaContactInformationTelephone");
neither works.
Is there a way to bind this declaratively or do I need a static method in a helper class somewhere?
Thanks.
Please understand this first: in the designer you've Fields mapped onto relations below every entity. These fields will become properties which will return one instance (in the case of fields mapped onto m:1 and 1:1 relations) or a collection (in the case of 1:n and m:n).
So if your field in the designer is called TelephoneCollectionViaContactInformationTelephone, then you'll never have a property in the entity called TelephoneCollection, but a property which is called TelephoneCollectionViaContactInformationTelephone.
With m:n relations there's something else: these are hidden by default because the designer often finds a lot of m:n relations and people often don't need them, so this leads to a lot of relations, code etc.. So please take these steps:
- in the designer, in the Contact entity, do you have a field mapped onto a relation called TelephoneCollectionViaContactInformationTelephone ?
- if so, is it hidden? This is visible through the dimmed icon in front of it.
- if it's hidden, it won't show up in your code. If it's hidden, it's likely the relation this field is mapped on is also hidden. Click open the relations node and please check if the m:n relation contact - telephone is indeed hidden (this is shown by the dimmed icon in front of it).
If it's hidden, simply right click it and select toggle hide BOTH sides. Also do that with the field TelephoneCollectionViaContactInformationTelephone. Then regenerate the code.