В дополнению к конфигурированию категорий в Модели Приложения, имеется возможность установить функциональность категорий для бизнес-объекта в коде, используя Xafari.BC.BOCategoryAttribute. Следующий фрагмент кода содержит пример применения Xafari.BC.BOCategoryAttribute.
[DefaultClassOptions]
[BOCategory("Customer", typeof(Customer),"Customer.Oid='{0:Oid}'"),
BOCategory("Employee", typeof(Employee), "Employee.Oid='{0:Oid}'")]
public class Order : BaseObject
{
//Description of the class
public Customer Customer
{
get { return this.GetPropertyValue<Customer>("Customer"); }
set { this.SetPropertyValue("Customer", value); }
}
public Employee Employee
{
get { return this.GetPropertyValue<Employee>("Employee"); }
set { this.SetPropertyValue("Employee", value); }
}
//Other fields of the class
…
…
…
}
Вы можете просмотреть полный код, используемый в этом примере, в файле Xafari.Northwind|Documents|Order.cs демо-приложения Xafari Northwind, установленного вместе с Xafari.