【发布时间】:2022-01-07 23:10:55
【问题描述】:
我知道this 的问题,但它已经很老了。
我的所有表单都有一个基类。它被称为FormPageModel,它是一个通用基类:
public class FormPageModel<ReadEntity, WriteEntity> where ReadEntity : class, IReadEntity, new(), where WriteEntity : class, IWriteEntity, new()
现在我希望能够使我的FormLayout.cshtml 成为我所有表单的基本布局,强类型。
我试过@model FormPageModel<IReadEntity, IWriteEntity>,但它没有编译。
我有办法在 Razor Pages 中使用泛型作为我的模型吗?
【问题讨论】:
标签: c# generics razor-pages