Search K
Appearance
An IdField is used to identify each entity based on its unique value.
An IdField<TEntity, TIdentifier> is created with two generic type arguments:
TEntity argument must be a reference type that refers to the underlying entity of the resource.TIdentifier argument represents the identifier type of the entity.INFO
We currently support string, Guid and int as identifier types.
The IdField defaults to a label 'ID' and a property name 'Id'. If your entity id deviates from that default you need to configure the field separately.
Unlike other fields, it's not added to the Fields method. Instead, it's configured with the PrimaryFieldBuilder method, which returns the IdField with its display and field name.
In our demo application, each Product has an int id.
public class Product
{
[Key]
public int Id { get; init; }
}We can represent the id with the non-standard name 'Product Id' in the product resource by overriding the PrimaryFieldBuilder:
public class ProductResource: Resource<Product, ApplicationDbContext, int>
{
protected override IPrimaryFieldBuilder<TEntity> PrimaryFieldBuilder =>
IdField<Employee, int>.Make("Product Id", nameof(Product.Id);
}An IdField displays its value as a link to the details page.

The default visibility values are as follows:
| Resource View | Default |
|---|---|
| Index | visible |
| Create | hidden |
| Update | hidden |
| Details | visible |
As the identifier for each entity is managed by the database, id fields are hidden by default in Create and Update views.