Table of Contents

Class ModelConfigAttribute

Namespace
Htmx.Components.Attributes
Assembly
Htmx.Components.dll

Marks methods in controllers that configure model handlers for specific model types. This attribute is used by the ModelHandlerAttributeRegistrar to automatically discover and register model handlers during application startup.

[AttributeUsage(AttributeTargets.Method)]
public class ModelConfigAttribute : Attribute
Inheritance
ModelConfigAttribute
Inherited Members
Extension Methods

Examples

[ModelConfig("users")]
private void ConfigureUserModel(ModelHandlerBuilder<User, int> builder)
{
    builder.WithKeySelector(u => u.Id)
           .WithQueryable(() => _context.Users)
           .WithTable(table => table.AddSelectorColumn(u => u.Name));
}

Remarks

Methods marked with this attribute must accept a single parameter of type ModelHandlerBuilder<T, TKey> and should configure the model handler for CRUD operations and table display.

Constructors

ModelConfigAttribute(string)

Initializes a new instance of the ModelConfigAttribute class.

public ModelConfigAttribute(string modelTypeId)

Parameters

modelTypeId string

The unique identifier for the model type.

Exceptions

ArgumentNullException

Thrown when modelTypeId is null.

Properties

ModelTypeId

Gets the unique identifier for the model type that this configuration applies to.

public string ModelTypeId { get; }

Property Value

string

A string that uniquely identifies the model type within the application.