Ok when I re-read the message it was a bit misunderstandable
Sorry for that.
The case is I do not want to create a relation; I already have it. I want to get the property for this relation's FK side.
Here's what I really want to do. I have a relation and I want to know the corresponding property for it at runtime.
I have the following entity:
OrderEntity
CustomerEntity **Customer **{get ; set;}//entity property for customerId field
...//some other fields/properties.
I have also the below relation that in fact states an order has a relation with customer entity.
OrderEntity.Relations.CustomerEntityUsingCustomerId
Is there a way to find from an EntityRelation object (for example OrderEntity.Relations.CustomerEntityUsingCustomerId) , the corresponding entity property (OrderEntity.Customer in this case) at runtime. Programatically I want to do something like
foreach (EntityRelation relation in RelationCollection){
relation.GetRelatedEntityPropertyName();
}
which should return the "[b]Customer[/b]" string when relation is equal to OrderEntity.Relations.CustomerEntityUsingCustomerId.
There is also a code like this in the OrderEntity Class:
private void SetupSyncCustomer(IEntity2 relatedEntity)
{
DesetupSyncCustomer(true);
if(relatedEntity!=null)
{
_customer = (CustomerEntity)relatedEntity;
_customer.ActiveContext = base.ActiveContext;
_customer.AfterSave+=new EventHandler(OnEntityAfterSave);
**base.SetEntitySyncInformation("Customer", _customer, OrderEntity.Relations.CustomerEntityUsingCustomerId);**
}
}
That information is what I need but I can't get it .
Hope I was clear this time.
Consider below as a second question:
If there is no way to do this at least I want to get a field's related property. For example I have customerId field and Customer property inside an OrderEntity. I have this field at runtime and I want to get the corresponding entity property for this