Relationships

Micron generates relationship methods for related models based on their foreign keys.

  [Foreign(typeof(Customer))]
  public Int32 CustomerID {get; set;}

During model creation, Micron parses through all the foreign keys and it generates one to many and one to one methods for each model. It uses singular and plurals for the method names depending on the localization reconfigured for micron.

Example, A customers table has a customer item which has many orders. Micron will generate two methods for customer model object.

customer.GetOrders(); //gets a collection of orders for customer
customer.HasOrers(); //check if customer has orders.

For this example.. an order has one customer, Micron will generate method bellow:

order.GetCustomer() //gets the customer object for the order

Last updated