Skip to content

Attributes reference

Class-level attributes:

AttributeTargetDescription
[CreateDto]ClassGenerates Create request with Validate() + ToEntity()
[UpdateDto]ClassGenerates Update request with Validate() + ApplyTo()
[CreateOrUpdateDto]ClassGenerates single DTO with ValidateForCreate/Update() + both
[ResponseDto]ClassGenerates read-only Response DTO with FromEntity() + ProjectFrom()
[QueryDto]ClassGenerates filter + sort DTO with nullable properties + ApplyFilter/ApplySort/Apply(IQueryable). Sortable defaults to true.
[QueryDto(Sortable = false)]ClassFilter-only DTO — skips SortBy, SortDirection, ApplySort(). For endpoints with a fixed result order.
[CrudApi]ClassGenerates full CRUD API endpoints + auto-implies missing DTOs
[CreateDtoFor(typeof(T))]Record (partial)Generates create DTO for external type T
[UpdateDtoFor(typeof(T))]Record (partial)Generates update DTO for external type T

Property-level attributes:

AttributeDescription
[DtoIgnore]Excludes from all generated DTOs (equivalent to DtoTarget.All)
[DtoIgnore(DtoTarget.X)]Excludes from specific DTO targets: Create, Update, Response, Query, List (combinable with |)
[DtoOnly(DtoTarget.X)]Includes only in the specified DTO target(s): e.g. DtoTarget.Create, DtoTarget.Update
[DtoName("json_name")]Overrides the JSON property name (works on all DTOs including Response)
[Flatten]Expands nested object properties into parent DTO (Response only)

Set-once fields: Use [DtoIgnore(DtoTarget.Update)] for properties that can be set at creation but never changed — the property won’t appear in the PATCH DTO at all.

[DtoName] on Response DTO:

[CrudApi]
public partial class Order
{
[DtoName("Customer")]
public string CustomerName { get; set; } // → "Customer" in response
[DtoName("Total")]
public decimal TotalAmount { get; set; } // → "Total" in response
}

Generated types:

TypeDescription
PaginatedResponse<T>Generic paginated wrapper with Items, TotalCount, Page, PageSize
DtoValidationResultPer-property validation errors with IsValid, Errors, AddError(), Merge(), ToDictionary()

Note: [PartialFrom], [IntersectFrom], [PickFrom], [OmitFrom] are in the separate ZibStack.NET.Core package.