Component Columns - HomeroThompson/firehawk GitHub Wiki

Component Columns

When an entity has a relationship with a component whose cardinality is one-to-one NH maps this component into the same table as the parent entity. In this case, you can customize the way the columns names are generated in order to distinguish the component columns from the entity columns.

The available conventions are:

PropertyName

The column name is generated with the same name as the property.

.ConfigureDomainModelConventions()
    .UseConventionForComponentColumnNames(ComponentsColumnsNamingConvention.PropertyName)
.EndConfig()

Example

public class Customer
{
    public virtual long ID { get; set; }
    public virtual string Name { get; set; }
    public virtual Address ShippingAddress { get; private set; }
}

public class Address
{
    public virtual string Street { get; protected set; }
    public virtual string Number { get; protected set; }
}

For the customer entity Firehawk will generate a table like this one:

ID Name Street Number
... ... ... ...
ComponentNamePropertyName

The column name is generated by appending the component name and the property name.

.ConfigureDomainModelConventions()
    .UseConventionForComponentColumnNames(ComponentsColumnsNamingConvention.ComponentNamePropertyName)
.EndConfig()

Example For the customer entity Firehawk will generate a table like this one:

ID Name AddressStreet AddressNumber
... ... ... ...
ComponentName_PropertyName

The column name is generated by appending the component name and the property name. In this case the underscore character is used as a word separator.

.ConfigureDomainModelConventions()
    .UseConventionForComponentColumnNames(ComponentsColumnsNamingConvention.ComponentName_PropertyName)
.EndConfig()

Example For the customer entity Firehawk will generate a table like this one:

ID Name Address_Street Address_Number
... ... ... ...
EntityPropertyNameComponentPropertyName

The column name is generated by appending the relationship property name and the component property name.

.ConfigureDomainModelConventions()
    .UseConventionForComponentColumnNames(ComponentsColumnsNamingConvention.EntityPropertyNameComponentPropertyName)
.EndConfig()

Example For the customer entity Firehawk will generate a table like this one:

ID Name ShippingAddressStreet ShippingAddressNumber
... ... ... ...
EntityPropertyName_ComponentPropertyName

The column name is generated by appending the relationship property name and the component property name. In this case the underscore character is used as a word separator.

.ConfigureDomainModelConventions()
    .UseConventionForComponentColumnNames(ComponentsColumnsNamingConvention.EntityPropertyName_ComponentPropertyName)
.EndConfig()

Example For the customer entity Firehawk will generate a table like this one:

ID Name ShippingAddress_Street ShippingAddress_Number
... ... ... ...
Custom

The column name is generated by a custom user defined function. This function accepts as input parameters the component type and the corresponding property member info.

.ConfigureDomainModelConventions()
    .UseCustomConventionForComponentColumnNames((c,p) => 
    {
    })
.EndConfig()