The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

How to: Link Classes Located in Different Assemblies

If you have access to the sources of the classes to be linked, use the AssociationAttribute with the AssociationAttribute.AssemblyName and AssociationAttribute.ElementTypeName as follows:


[Association("CustomersOrderLink", "CustomerAssembly", "CustomerAssembly.Customer")]
public Customer.Customer Customer { get; set; }
// ...
[Association("CustomersOrderLink", "OrderAssembly", "OrderAssembly.Order")]
public XPCollection Orders { get; }

When you cannot modify the sources of the classes to be linked, you can introduce an intermediate class:


public class CustomerToOrderLink {
    public Customer Customer;
    public Order Order;
}

Or, define an association dynamically at runtime, using the XPClassInfo.CreateMember method.


XPClassInfo customerInfo = dictionary.GetClassInfo(typeof(Customer));
XPClassInfo orderInfo = dictionary.GetClassInfo(typeof(Order));
customerInfo.CreateMember("Orders", typeof(XPCollection<Order>), true, false, new AssociationAttribute("Customer-Orders", typeof(Order)));
orderInfo.CreateMember("Customer", customerInfo, new AssociationAttribute("Customer-Orders"));