Home / Model Definition

Code Example

The data in this demo uses the following model code:

C#

using System.ComponentModel.DataAnnotations;

namespace EZAccessDataDemo.Models;

public class Contact
{
    [Editable(false)]
    [Key]
    public int Id { get; set; }

    [Required]
    [MinLength(2)]
    [MaxLength(50)]
    public string? Name { get; set; }

    [DisplayFormat(DataFormatString = "d")]
    [Range(typeof(DateTime), "01/01/1950", "01/01/2200")]
    public DateTime? Birthday { get; set; }

    [Range(-10, 10)]
    public int Score { get; set; }

    [MaxLength(50)]
    public string? Address { get; set; }

    [Display(Name = "Postal code")]
    [MaxLength(10)]
    public string? PostalCode { get; set; }

    [MaxLength(50)]
    public string? City { get; set; }

    [Editable(false)]
    public int Version { get; set; }
}
                            
An error has occurred. This application may no longer respond until reloaded. Reload 🗙