小编Bry*_*003的帖子

在 Blazor 组件中使用具有继承的泛型类型

我正在尝试在 Blazor 中创建一个“通用列表”组件,并希望该组件能够接受从基类派生的任何对象。我的代码目前如下;

基类:

    public class Model
    {

        // PK for the record
        [Key]
        public int Id { get; set; }

        // holds the front-end name for the record
        [Required(ErrorMessage = "Name is required")]
        public string Name { get; set; } = "";

        // holds the date and time the record was created
        [Required(ErrorMessage = "Created Timestamp is required")]
        public DateTime Created { get; set; } = DateTime.Now;

        // holds the username of the person who created the record
        [Required(ErrorMessage …
Run Code Online (Sandbox Code Playgroud)

c# generics razor blazor

1
推荐指数
1
解决办法
1484
查看次数

标签 统计

blazor ×1

c# ×1

generics ×1

razor ×1