-
Notifications
You must be signed in to change notification settings - Fork 36
Property configuration
Like for entity, for property configuration you can use attributes or fluent configuration.
Fluent:
Entity<Customer>.Add()
.ConfigureProperty(PropertyOf<Customer>.Configure(c => c.CompanyName))
And now you ready to configure a CompanyName property.
Attribute:
[Column("CompanyName")]
public string CompanyName { get; set; }
Fluent:
PropertyOf<Customer>.Configure(c => c.CompanyName).SetColumnName("CompanyName");
Attribute:
[OnDelete(DeleteOption.SetNull)]
public ICollection<Order> Orders { get; set; }
Fluent:
PropertyOf<Customer>.Configure(c => c.Orders).OnDelete(DeleteOption.CascadeDelete)
Attribute:
[Key]
public string CustomerId { get; set; }
Fluent:
PropertyOf<Customer>.Configure(c => c.CustomerId).IsKey()
Attribute:
[Display(Name = "Company")]
public string CompanyName { get; set; }
Fluent:
PropertyOf<Customer>.Configure(c => c.CompanyName).SetDisplayName("Company")
Templates are automatically determined based on property type.
But you can change template. You can create own custom template and pass their name to Ilaro.Admin.
You can also override existing partial view, Attribute:
[Template(DisplayTemplate = Templates.Display.Html, EditorTemplate = Templates.Editor.Html)]
public string Address { get; set; }
Fluent:
PropertyOf<Customer>.Configure(c => c.CompanyName)
.SetDisplayTemplate(Templates.Display.Html)
.SetEditorTemplate(Templates.Editor.Html)
Attribute:
Fluent:
To make an attribute Nullable (not required), the underlying type has to be Nullable (notice the question mark after the type). Apparently, there's no way to make property Nullable using Fluent configuration. All properties that are not marked as Nullable are treated as Required in the View.
Attribute:
public DateTime? ArrivalDate { get; set; }