要创建通用基类,我想将字段的类型存储在变量中。这样的事情(这是行不通的):
public class MyClass
{
public MyClass()
{
myType = typeof(string);
}
public Type myType { get; set; }
public myType MyProperty { get; set; }
}
我通过Entity Framework Core从具有70多个表的数据库中处理了许多模型和模型的ObservableCollections,并且我不想因为更改类型而为每个表复制/粘贴(DRY!)业务逻辑。
除了我想出的方法之外,还有其他方法吗?