Hi:
I am having the exact same problem. I have some table relations very similar to your example and have the same compile problems.
I narrowed the source from this a little more and found something (Generating the solution project for the above db struct using nettiers rev 563 from svn trunk):
The class CustomerOrdersBase (from TestM2M.Entities\CustomerOrdersBase.generated.cs) have the following Source Fields (I am removing the xml comments for readability):
public virtual Customers CustomerIDCustomerTypeIDSource
{
get { return entityData.CustomerIDCustomerTypeIDSource; }
set { entityData.CustomerIDCustomerTypeIDSource = value; }
}
public virtual Orders OrderIDSource
{
get { return entityData.OrderIDSource; }
set { entityData.OrderIDSource = value; }
}
But the related OrdersProviderBaseCore class (from TestM2M.Data\Bases\OrdersProviderBaseCore.generated.cs) is trying to access those fields using the following code (DeepSave Method, line 483):
foreach(CustomerOrders child in entity.CustomerOrdersCollection)
{
if(child.OrderIDSource != null)
child.OrderID = child.OrderIDSource.OrderID;
else
child.OrderID = entity.OrderID;
//Handle right table of CustomersCollection_From_CustomerOrders
if(child.CustomerIDSource != null)
child.CustomerID = child.CustomerIDSource.CustomerID;
//Handle right table of CustomersCollection_From_CustomerOrders
if(child.CustomerTypeIDSource != null)
child.CustomerTypeID = child.CustomerTypeIDSource.CustomerTypeID;
}
As you can see, nettiers is generating the above code referencing each source property of the CustomerOrdersBase class as individual properties instead of using CustomerIDCustomerTypeIDSource.
Same thing happens on the other relation endpoint in TestM2M.Data\Bases\CustomersProviderBaseCore.generated.cs (DeepSave method, line 499)
I dont know wich one is wrong as I am really new using nettiers, but looks like there is some mismatch when generating / using the Source properties from a M2M relation with multiple foreign keys as in this example.
I modified the generated code of the OrdersProviderBaseCore class to this:
//Handle right table of CustomersCollection_From_CustomerOrders
if(child.CustomerIDCustomerTypeIDSource != null)
child.CustomerID = child.CustomerIDCustomerTypeIDSource.CustomerID;
//Handle right table of CustomersCollection_From_CustomerOrders
if(child.CustomerIDCustomerTypeIDSource != null)
child.CustomerTypeID = child.CustomerIDCustomerTypeIDSource.CustomerTypeID;
And made a similar change to CustomersProviderBaseCore and now it compiles, but well, I dont know if this is the correct approach or the CustomerOrders class should be the one to be changed. I will run some Unit Tests on it and check to see if i find some problems with this change, but well, if any of the nettiers dev members can check this it will be nice. :D
I hope this help.
Best regards and sorry for my bad english. :(