Project Description
Shows how to use PostSharp to allow the use of one-way associations in the Express Persistent Objects (XPO) ORM from Developer Express.


Typically in the Express Persistent Objects (XPO) ORM from Developer Express you cannot have one-way collection associations like:

public class Customer: XPObject
{
  public XPCollection<Order> Orders 
  { 
    get { return GetCollection<Order>("Orders"); } 
  }
}

public class Order: XPObject
{
}


XPO is designed so that you have to implement the other end of the association in your object model:

public class Customer: XPObject
{
  [Association("CustomerOrders")]
  public XPCollection<Order> Orders 
  { 
    get { return GetCollection<Order>("Orders"); } 
  }
}

public class Order: XPObject
{
  [Association("CustomerOrders")]
  public Customer Customer;
}


This project uses PostSharp to let you implement one-way collection associations in XPO, leading to writing less code:

Further Reading
  • More details are on my blog here.
  • You can also see how to use PostSharp to allow you to use C# automatic properties with XPO here. This work was inspired by Ruurd Boeke's articles on using PostSharp.Core and I recommend anyone interested in PostSharp reads them too.
  • Read how you can use PostSharp to allow the use of C# automatic properties in XPO.

Requirements
You will need PostSharp version 1.0.
There are two solutions in the attached code: one that processes XPO classes and one with no dependencies on XPO but shows how to add a field and custom attributes using PostSharp.Core.
If you want to open the XPO solution you will also need XPO (I've used version 8.2 trial).

Search Paths
With either solution you will need to change the search paths of the projects so that they can find the weaver project. To do this just open the projects in the solution and change the search paths where they are set.

searchpaths.png

If you don't do this you will get an error when you compile:

error.png

Last edited Nov 2, 2008 at 6:29 PM by SeanKearon, version 4