I have a template for Municipality. This model can be referenced by several other models (Customer, Supplier, Carrier, Salesman ...). Each of these models has an association N: 1 for Municipio, +/- thus:
public class Cliente: XPLiteObject {
...
Municipio: fMunicipio;
[Association]
public Municipio Municipio {
get { return fMunicipio; }
set { SetPropertyValue("Municipio", ref fMunicipio, value); }
}
According to the XPO documentation, I must declare this association at the other end, in the Municipio model, +/- thus:
public class Municipio: XPLiteObject {
...
[Association]
public XPCollection<Cliente> Clientes {
get { return GetCollection<Order>("Clientes"); }
}
}
I do not want (do not like) to declare this association in the model Municipio, because I will not refer to the list of clients from Municipality. And also because I would have several models referencing Municipio, and I do not need to get the list of any of them from Municipality. Another problem is that the model Municipio is already tested, and when I add another model referencing Municipio, eg Distributor, I do not want to change the Municipio model, adding another association in it.
My question is whether the association at the other end (Municipio) is obligatory for each associated model (Client, Vendor ...), or if I can keep the reference only in the model that maintains the relation. And, if it is mandatory, I should name each of the associations to disambiguate the references, like this:
public class Municipio: XPLiteObject {
...
[Association("Cliente-Municipio)]
public XPCollection<Cliente> Clientes {
get { return GetCollection<Order>("Clientes"); }
}
[Association("Fornecedor-Municipio)]
public XPCollection<Fornecedor> Fornecedores {
get { return GetCollection<Order>("Formecedores"); }
}
}
public class Cliente: XPLiteObject {
...
Municipio: fMunicipio;
[Association("Cliente-Municipio)]
public Municipio Municipio {
get { return fMunicipio; }
set { SetPropertyValue("Municipio", ref fMunicipio, value); }
}
public class Fornecedor: XPLiteObject {
...
Municipio: fMunicipio;
[Association("Fornecedor-Municipio)]
public Municipio Municipio {
get { return fMunicipio; }
set { SetPropertyValue("Municipio", ref fMunicipio, value); }
}