dazinator / CrmAdo

An ADO.NET Provider for Dynamics Crm
6 stars 4 forks source link

The special crm fields for address1_id and address2_id are being reported up as primary keys #68

Closed dazinator closed 9 years ago

dazinator commented 9 years ago

On certain entities in CRM, like

  1. Account
  2. Contact

There are mutiple address fields.

Dynamics has some magic on these entities, that make it look like the address fields are directly held on the same entity, but really these entities store the primary key id of a seperate address entity which holds the address data, so really these are foreign keys, and dynamics crm automatically pulls the related address records into the current entity and exposes it in a flattened form by prefixing address field names with address1, then address2 etc etc.

When CrmAdo queries the metadata columns for an entity to get the column that is flagged with IsPrimary - the attribute that represents the primary key is returned, however so are these address1_id and address2_id columns. This is rubbish of the SDK. I will need to find some other filter criteria on which I can filter those foreign keys out so that CrmAdo's GetSchema methods doesn't report them as primary keys.