Spiderly Attributes

AuthGuardAttribute

Namespace: Spiderly.Shared.Attributes

Usage:

Provides authentication protection for API endpoints by validating JWT tokens in the request.

BlobNameAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Marks a string property as a reference to a file stored in Azure Blob Storage. This property will contain the unique identifier (blob name) used to locate and access the file in Azure Storage.

Example:


public class User : BusinessObject<long>
{
    [BlobName]
    public string ProfilePictureBlobName { get; set; }
}
    

CascadeDeleteAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Implements cascade delete behavior in many-to-one relationships. When the referenced entity is deleted, all entities that reference it will automatically be deleted as well.

This attribute is useful when:

- Child entities should not exist without their parent
- You want cascade delete but don't need the strict validation of [ManyToOneRequired]

Example:


public class Comment : BusinessObject<long>
{
    [DisplayName]
    public string Text { get; set; }

    [CascadeDelete] // When the Post is deleted, all its Comments will be deleted
    [WithMany(nameof(Post.Comments))]
    public virtual Post Post { get; set; }
}
    

ControllerAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies a custom controller name for an entity, overriding the default naming convention. This attribute allows grouping multiple related entities under a single controller.

Default behavior without 'Controller' attribute:

Controllers are named as '{EntityName}Controller'

Example:


[Controller("SecurityController")]
public class User { }

[Controller("SecurityController")]
public class Role { }

[Controller("SecurityController")]
public class Permission { }
    

CustomMapperAttribute

Namespace: Spiderly.Shared.Attributes

Usage:

Marks a class for custom object mapping implementation.

Example:


[CustomMapper]
public static partial class Mapper
{
    // Custom mapping methods
}
    

Note:

Use this attribute when you need to implement specialized mapping logic that cannot be handled by the default mapping configuration.

CustomValidatorAttribute

Namespace: Spiderly.Shared.Attributes

Usage:

Specifies a custom validation rule to be applied to the decorated property.
Multiple validation rules can be chained together using dot notation e.g. EmailAddress().Length(5, 10)

Example:


public class User : BusinessObject<long>
{
    [CustomValidator("EmailAddress().Length(5, 50)")] // Validates email format and length
    public string Email { get; set; }
}
    

DisplayNameAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies which property should be used as the display name for an entity in UI elements:
- When applied to a property: The property's value will be used to represent the entity
- When applied to a class: The specified property's value will be used to represent the entity
- If no property or class is marked with this attribute: The entity's 'Id' will be used

Example:


public class User : BusinessObject<long>
{
    [DisplayName]
    public string FullName { get; set; } // Will be used in dropdowns and lists
}

[DisplayName("Department.Name")] // Uses related entity's property
public class Employee : BusinessObject<long>
{
    public virtual Department Department { get; set; }
}
    

DoNotAuthorizeAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Disables authorization checks for CRUD operations on the decorated entity. By default, all entities require authorization for CRUD operations.

Warning:

This attribute bypasses security checks and should be used with extreme caution. It is primarily intended for testing purposes and should generally be avoided in production environments.

ExcludeFromDTOAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies that a property should be excluded from the generated DTO.

ExcludeServiceMethodsFromGenerationAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Prevents the generation of standard business service methods for the decorated property in the BusinessServiceGenerated class.

Use this attribute when you want to:

- Implement custom business logic instead of using generated methods
- Override the default generated behavior with your own implementation
- Exclude specific properties from the standard service method generation

Note:

The property will still be part of the entity, but no service methods will be generated for it in the BusinessServiceGenerated class.

GenerateCommaSeparatedDisplayNameAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Generates a string property in the DTO containing comma-separated display names for a collection property in the entity.

Example:


public class Project : BusinessObject<long>
{
    [DisplayName]
    public string Name { get; set; }

    [GenerateCommaSeparatedDisplayName]
    public virtual List<User> TeamMembers { get; set; } = new();
}

public class User : BusinessObject<long>
{
    [DisplayName]
    public string Email { get; set; }
}

// In the UI table, the TeamMembers column will show:
// "john@example.com, jane@example.com, bob@example.com"
    

GreaterThanOrEqualToAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Validates that a numeric property value is greater than or equal to a specified number. This attribute provides both server-side and client-side validation.

IncludeInDTOAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies that a property should be included in the generated DTO. This attribute is particularly useful for enumerable properties, which are not included in DTOs by default.

Note:

This attribute only affects DTO generation and does not influence the mapping behavior (Entity <-> DTO).

M2MEntityAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Marks a property in a many-to-many relationship where the administration of the relationship should NOT be performed. This attribute is used in conjunction with M2MMaintanceEntity to define the relationship management structure.

Example:


public class RolePermission
{
    [M2MMaintanceEntity(nameof(Role.Permissions))]
    public virtual Role Role { get; set; }

    [M2MEntity(nameof(Permission.Roles))]
    public virtual Permission Permission { get; set; }
}
    

M2MMaintanceEntityAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Marks a property in a many-to-many relationship where the administration of the relationship should be performed. This attribute indicates that the current entity's page will contain the UI controls for managing the many-to-many relationship.

Example:


public class RolePermission
{
    [M2MMaintanceEntity(nameof(Role.Permissions))]
    public virtual Role Role { get; set; }

    [M2MEntity(nameof(Permission.Roles))]
    public virtual Permission Permission { get; set; }
}
    

ManyToOneRequiredAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies that a many-to-one relationship property is required and should trigger cascade delete. This attribute generates both backend and frontend validation rules to ensure the relationship is always present.

When applied to a property:

- Enforces that the parent entity cannot exist without this relationship
- Implements cascade delete behavior
- Generates required validation rules for both backend and frontend

Example:


public class User : BusinessObject<long>
{
    [ManyToOneRequired]
    [WithMany(nameof(Gender.Users))]
    public virtual Gender Gender { get; set; }
}
    

OutputAttribute

Namespace: Spiderly.Shared.Attributes

Usage:

Specifies the output configuration for the Source Generator.

Note:

This is a temporary solution and may be replaced in future versions.

ProjectToDTOAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies custom mapping configuration when projecting an entity to its DTO.

Example:


[ProjectToDTO(".Map(dest => dest.TransactionPrice, src => src.Transaction.Price)")]
public class Achievement : BusinessObject<long>
{
    // Properties
}
    

SetNullAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies that the property should be set to null when the parent entity is deleted.
Apply this attribute to a many-to-one relationship property.

SimpleManyToManyTableLazyLoadAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies that a table items for the many-to-many relationship administration should be loaded lazily (on-demand) rather than eagerly.

SkipSpinnerAttribute

Namespace: Spiderly.Shared.Attributes

Usage:

Indicates that the loading spinner should be skipped for the decorated controller method.

Use when:

- The operation is very quick and doesn't need a loading indicator
- You want to implement custom loading behavior
- The operation runs in the background

Example:


[HttpGet]
[SkipSpinner]
public async Task SendNotificationEmail(long notificationId)
{
    await SendNotificationEmail(notificationId);
}
    

TranslateExcelEnAttribute

Namespace: Spiderly.Shared.Attributes.EF.Translation

Usage:

Specifies the English name for the exported Excel file.

If not specified:

- First tries to use TranslatePluralEn value
- If TranslatePluralEn is not available, uses '{class_name}List'

Example:


[TranslateExcelEn("Users_Excel")]
public class User : BusinessObject<long>
{
    // Class properties
}
// Will generate: Users_Excel.xlsx
    

TranslateExcelSrLatnRSAttribute

Namespace: Spiderly.Shared.Attributes.EF.Translation

Usage:

Specifies the Serbian Latin name for the exported Excel file.

If not specified:

- First tries to use TranslatePluralSrLatnRS value
- If TranslatePluralSrLatnRS is not available, uses '{class_name}List'

Example:


[TranslateExcelSrLatnRS("Korisnici_Excel")]
public class User : BusinessObject<long>
{
    // Class properties
}
// Will generate: Korisnici_Excel.xlsx
    

TranslatePluralEnAttribute

Namespace: Spiderly.Shared.Attributes.EF.Translation

Usage:

Specifies the English plural form translation for a class.

This translation is used for:

- Table titles
- Excel export filenames (when TranslateExcelEn is not specified)

Example:


[TranslatePluralEn("User points")]
public class UserPoint : BusinessObject<long>
{
    // Class properties
}
// Will show as "User points" in table headers
// Will export as "User points.xlsx" if TranslateExcelEn is not specified
    

TranslatePluralSrLatnRSAttribute

Namespace: Spiderly.Shared.Attributes.EF.Translation

Usage:

Specifies the Serbian Latin plural form translation for a class.

This translation is used for:

- Table titles
- Excel export filenames (when TranslateExcelSrLatnRS is not specified)

Example:


[TranslatePluralSrLatnRS("Korisnički poeni")]
public class UserPoint : BusinessObject<long>
{
    // Class properties
}
// Will show as "Korisnički poeni" in table headers
// Will export as "Korisnički poeni.xlsx" if TranslateExcelSrLatnRS is not specified
    

TranslateSingularEnAttribute

Namespace: Spiderly.Shared.Attributes.EF.Translation

Usage:

Specifies the English singular form translation for a class or property.

When applied to a class:

- Used in base form details UI component title

Example:


[TranslateSingularEn("User point")]
public class UserPoint : BusinessObject<long>
{
    // Class properties
}
    


When applied to a property:

- Used as UI field label
- Used in server validation messages (e.g., Field 'Email address' can not be empty")

Example:


public class User : BusinessObject<long>
{
    [TranslateSingularEn("Email address")]
    public string Email { get; set; }
}
    

TranslateSingularSrLatnRSAttribute

Namespace: Spiderly.Shared.Attributes.EF.Translation

Usage:

Specifies the Serbian Latin singular form translation for a class or property.

When applied to a class:

- Used in base form details UI component title

Example:


[TranslateSingularSrLatnRS("Korisnički poen")]
public class UserPoint : BusinessObject<long>
{
    // Class properties
}
    


When applied to a property:

- Used as UI field label
- Used in server validation messages (e.g., Polje 'Email adresa' ne sme biti prazno")

Example:


public class User : BusinessObject<long>
{
    [TranslateSingularSrLatnRS("Email adresa")]
    public string Email { get; set; }
}
    

UIAdditionalPermissionCodeForInsertAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies additional permission requirements for inserting entities in the UI. The user must have ONE of the specified permissions to perform the insert operation. Multiple instances of this attribute can be applied to a single entity.

UIAdditionalPermissionCodeForUpdateAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies additional permission requirements for updating entities in the UI. The user must have ONE of the specified permissions to perform the update operation. Multiple instances of this attribute can be applied to a single entity.

UIControlTypeAttribute

Namespace: Spiderly.Shared.Attributes.EF.UI

Usage:

Specifies the UI control type for a property.

If not specified, the control type is automatically determined based on the property type:
- string: TextBox (or TextArea if [StringLength] value is large)
- int/long: Number
- decimal: Decimal
- bool: CheckBox
- DateTime: Calendar
- many-to-one: Autocomplete

Example:


public class User : BusinessObject<long>
{
    [UIControlType(nameof(UIControlTypeCodes.Dropdown))]
    public UserType Type { get; set; }

    [UIControlType(nameof(UIControlTypeCodes.TextArea))]
    public string Description { get; set; }

    // Automatically becomes a TextBox
    public string Name { get; set; }

    // Automatically becomes a Number
    public int Age { get; set; }
}
    

UIControlWidthAttribute

Namespace: Spiderly.Shared.Attributes.EF.UI

Usage:

Specifies the width of a UI field using PrimeNG (PrimeFlex) column classes.

Default values:

- "col-12" for TextArea and Editor controls
- "col-12 md:col-6" for all other controls

Example:


public class Article : <long>
{
    [UIControlWidth("col-12")]
    [UIControlType(nameof(UIControlTypeCodes.TextArea))]
    public string Content { get; set; }

    [UIControlWidth("col-3")]
    public string Author { get; set; }

    // Uses default "col-12 md:col-6"
    public string Title { get; set; }
}
    

UIDoNotGenerateAttribute

Namespace: Spiderly.Shared.Attributes.EF.UI

Usage:

Excludes a property from being generated in the UI main form component.

Example:


public class User : BusinessObject<long>
{
    public string Name { get; set; }

    [UIDoNotGenerate]
    public DateTime LastLoginDate { get; set; } // Won't appear in the UI form

    [UIDoNotGenerate]
    public string InternalNotes { get; set; } // Won't appear in the UI form
}
    

UIOrderedOneToManyAttribute

Namespace: Spiderly.Shared.Attributes.EF.UI

Usage:

Enables management of child entities through an ordered list in the parent entity's main UI form component.

Example:


public class Course : BusinessObject<long>
{
    [DisplayName]
    public string Name { get; set; }

    [UIOrderedOneToMany]
    public virtual List<Course> Courses { get; set; } = new(); // Will be shown as an ordered list in the UI
}

public class CourseItem : BusinessObject<long>
{
    [DisplayName]
    public string Title { get; set; }

    [UIDoNotGenerate]
    [Required]
    public int OrderNumber { get; set; } // Needs to be called OrderNumber

    [ManyToOneRequired] // The course item can't exist without the course
    [WithMany(nameof(Course.CourseItems))]
    public virtual Course Course { get; set; }
}
    

UIPanelAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies in which panel the UI control will be located. By default, all controls are inside the "Details" panel.

Example:


public class User : BusinessObject<long>
{
    [DisplayName]
    public string Name { get; set; } // Goes to "Details" panel by default

    [UIPanel("Security")]
    public string Password { get; set; } // Goes to "Security" panel

    [UIPanel("Preferences")]
    public bool ReceiveNotifications { get; set; } // Goes to "Preferences" panel
}
    

UIPropertyBlockOrderAttribute

Namespace: Spiderly.Shared.Attributes.EF.UI

Usage:

Specifies the display order of UI controls. Controls are displayed in the order of property declaration, except for: 'file', 'text-area', 'editor', and 'table' controls, which are always displayed last in their declaration order.

Example:


public class Article : BusinessObject<long>
{
    [UIPropertyBlockOrder("1")]
    public string Title { get; set; }

    [UIPropertyBlockOrder("2")]
    public string Author { get; set; }

    // Will be displayed last despite order number
    [UIPropertyBlockOrder("0")]
    [UIControlType(nameof(UIControlTypeCodes.TextArea))]
    public string Content { get; set; }
}
    

UITableColumnAttribute

Namespace: Spiderly.Shared.Attributes.EF.UI

Usage:

Specifies which columns should be displayed in a table view for a many-to-many relationship. Must be used in combination with [SimpleManyToManyTableLazyLoad] attribute.

Example:


public class Partner : BusinessObject<long>
{
    [DisplayName]
    public string Name { get; set; }

    #region UITableColumn
    [UITableColumn(nameof(PartnerUserDTO.UserDisplayName))]
    [UITableColumn(nameof(PartnerUserDTO.Points))]
    [UITableColumn(nameof(PartnerUserDTO.TierDisplayName))]
    [UITableColumn(nameof(PartnerUserDTO.CheckedSegmentationItemsCommaSeparated), "Segmentation")] // Custom translation key
    [UITableColumn(nameof(PartnerUserDTO.CreatedAt))]
    #endregion
    [SimpleManyToManyTableLazyLoad]
    public virtual List<PartnerUser> Recipients { get; set; } = new(); // M2M relationship
}
    

WithManyAttribute

Namespace: Spiderly.Shared.Attributes.EF

Usage:

Specifies the collection navigation property name in a related entity for establishing a bidirectional relationship in Entity Framework.

Purpose:

This attribute is used to define the inverse navigation property in a relationship, enabling proper relationship configuration and navigation in both directions.

Example:


public class Course : BusinessObject<long>
{
    public virtual List<Student> Students { get; set; } = new();
}

public class Student : BusinessObject<long>
{
    [WithMany(nameof(Course.Students))]
    public virtual Course Course { get; set; }
}