Defines a 1-n relationship for a child object.
Example:
[ElementaryClass]
public class Customer
{
[Persist]
public string FirstName;
[Persist]
public string LastName;
[HasMany(typeof(Order))]
public List<Order> Orders;
}Remarks
Elementary will automatically infer the parent and child columns to use. Let's assume that this is our table structure:
Customer -------------------- - CustomerId - FirstName - LastName Order -------------------- - OrderId - CustomerId
If the columns aren't explicitly defined, Elementary will look for the following matches:
Orders.CustomerId (Plural - SingularId)
Orders.Customer_id (Plural - Singular_Id)
Orders.CustomersId (Plural - PluralId)
Orders.Customers_Id (Plural - Plural_Id)
Order.CustomerId (Plural - Child PK)
Order.CustomerId (Singular - SingularId)
Order.Customer_id (Singular - Singular_Id)
Order.CustomersId (Singular - PluralId)
Order.Customers_Id (Singular - Plural_Id)
Order.CustomerId (Singular - Child PK)
Options
| ChildColumn | Defines the column to use in the child table[ElementaryClass]
public class Customer
{
[Persist]
public string FirstName;
[Persist]
public string LastName;
[HasMany(typeof(Order), ParentColumn="customerid", ChildColumn="customerid")]
public List<Order> Orders;
}
|
| ParentColumn | Defines the column to use in the parent table[ElementaryClass]
public class Customer
{
[Persist]
public string FirstName;
[Persist]
public string LastName;
[HasMany(typeof(Order), ParentColumn="customerid", ChildColumn="customerid")]
public List<Order> Orders;
}
|
| ChildProperty | Defines the property to use in the child table. This is translated behind the scenes into the corresponding column[ElementaryClass]
public class Customer
{
[Persist]
public string FirstName;
[Persist]
public string LastName;
[HasMany(typeof(Order), ParentProperty="Id", ChildProperty="CustomerId")]
public List<Order> Orders;
}
|
| ParentProperty | Defines the property to use in the parent table. This is translated behind the scenes into the corresponding column[ElementaryClass]
public class Customer
{
[Persist]
public string FirstName;
[Persist]
public string LastName;
[HasMany(typeof(Order), ParentProperty="Id", ChildProperty="CustomerId")]
public List<Order> Orders;
}
|