Hi chuckc,
Getting the type of the child entity is fairly simple:
var np = aPerson.EntityAspect.GetNavigationProperty("Gender").RelationLink.ToNavigationEntityProperty;
Type navPropertyEntityType = np.RelationLink.ToRole.EntityType; // type is Gender
As for getting the FK value, you will need to first get the DataEntityProperty that corresponds to the FK and then get its value:
Guid fkId = (Guid)aPerson.EntityAspect.GetValue(GetFkProp(np).Name);
.
.
.
public DataEntityProperty GetFkProp(NavigationEntityProperty np) {
var fkProps = EntityMetadataStore.Instance.GetEntityMetadata(np.EntityType).ForeignKeyProperties;
var result = fkProps.FirstOrDefault(fkProp =>
ReflectionFns.GetAttribute<ForeignKeyAttribute>(fkProp.PropertyInfo).RelatedNavigationPropertyName == np.Name);
return result;
}
I hope this helps.
Could you share with us what your use case is? It's worth knowing it and this might be a good candidate for a feature in the product.
Regards,
Silvio.
Edited by sbelini - 02-Jun-2011 at 4:23pm