Table of Contents

Class TableMetadataForAttribute

Namespace
BootstrapBlazor.Components
Assembly
BootstrapBlazor.dll

Define a group of UI generation metadata for target data type Usually model types are at different layer to the blazor component UI layer. In this case, use TableMetadataForAttribute to define a metadata type for Table component. Then register metadata type with TableMetadataTypeService Example: the Pig data type is usually at biz or data layer

public class Pig
{
public string? Name1 { get; set; }

    public string? Name2 { get; set; }
}</code></pre>
the PigMetadata can be defined at UI/component layer
<pre><code class="lang-csharp">[TableMetadataFor(typeof(Pig))]
[AutoGenerateClass(Align = Alignment.Center)]
public class PigMetadata
{
    [AutoGenerateColumn(Ignore = true)]
    public string? Name1 { get; set; }

    [AutoGenerateColumn(Align = Alignment.Center, Order = -2)]
    public string? Name2 { get; set; }
}</code></pre>
before using the metadata, it needs to register the metadata types.
register metadata types in assembly
<pre><code class="lang-csharp">TableMetadataTypeService.RegisterMetadataTypes(typeof(Pig).Assembly);
var cols = Utility.GetTableColumns<Pig>().ToList();
Assert.Single(cols);</code></pre>
or you can register types individually
<pre><code class="lang-csharp">TableMetadataTypeService.RegisterMetadataType(metadataType, dataType);</code></pre></example>
[AttributeUsage(AttributeTargets.Class)]
public class TableMetadataForAttribute : Attribute
Inheritance
TableMetadataForAttribute
Inherited Members
Extension Methods

Remarks

Constructor TableMetadataForAttribute for target data type

Constructors

TableMetadataForAttribute(Type)

Define a group of UI generation metadata for target data type Usually model types are at different layer to the blazor component UI layer. In this case, use TableMetadataForAttribute to define a metadata type for Table component. Then register metadata type with TableMetadataTypeService Example: the Pig data type is usually at biz or data layer

public class Pig
{
public string? Name1 { get; set; }

    public string? Name2 { get; set; }
}</code></pre>
the PigMetadata can be defined at UI/component layer
<pre><code class="lang-csharp">[TableMetadataFor(typeof(Pig))]
[AutoGenerateClass(Align = Alignment.Center)]
public class PigMetadata
{
    [AutoGenerateColumn(Ignore = true)]
    public string? Name1 { get; set; }

    [AutoGenerateColumn(Align = Alignment.Center, Order = -2)]
    public string? Name2 { get; set; }
}</code></pre>
before using the metadata, it needs to register the metadata types.
register metadata types in assembly
<pre><code class="lang-csharp">TableMetadataTypeService.RegisterMetadataTypes(typeof(Pig).Assembly);
var cols = Utility.GetTableColumns<Pig>().ToList();
Assert.Single(cols);</code></pre>
or you can register types individually
<pre><code class="lang-csharp">TableMetadataTypeService.RegisterMetadataType(metadataType, dataType);</code></pre></example>
public TableMetadataForAttribute(Type dataType)

Parameters

dataType Type

The target model/data type

Remarks

Constructor TableMetadataForAttribute for target data type

Properties

DataType

The target model/data type

public Type DataType { get; }

Property Value

Type