Entities

Entity definitions need to follow certain rules in order to work with Xams.

Entity Rules

  1. Entities should have either a string Name field or a string field with the attribute UIName for lookup fields.
  2. Composite Primary Keys are not supported.

Cascade Delete

Configure cascade delete using the nullable operator ? and the CascadeDelete attribute.

Project.Common / Entities / Widget.cs

[Table("Widget")]
public class Widget : BaseRecord
{
public Guid WidgetId { get; set; }
// Name is not nullable and required
public string Name { get; set; }
// Company is not nullable making it required
// Deleting the Company deletes this record
public Guid CompanyId { get; set; }
public Department Company { get; set; }
// Manufacturer is nullable making it optional
// Deleting the Manufacturer sets this to null
public Guid? ManufacturerId { get; set; }
public Manufacturer? Manufacturer { get; set; }
// Contact is nullable but the UIRequired attribute makes it required
// Deleting the contact sets this to null
[UIRequired]
public Guid? ContactId { get; set; }
public Contact Contact { get; set; }
// Address is nullable making it optional
// The CascadeDelete attribute deletes this
// record when the Address is deleted
[CascadeDelete]
public Guid? AddressId { get; set; }
public Address Address { get; set; }
}

Was this page helpful?