实现动态泛型抽象类的解决方案

时间:2018-02-12 16:33:50

标签: c# .net generics dynamic abstract

嘿,我有这样的代码

public abstract class SqlQueryDynamicTmpl<TSelf, TParams, TResult> : 
SqlCmdQueryInternalBase<TParams, TResult>
where TSelf : SqlQueryDynamicTmpl<TSelf, TParams, TResult>, new()
where TParams : class, SqlCmdQueryInternalBase<TParams, TResult>.IParams
where TResult : class, SqlCmdQueryInternalBase<TParams, TResult>.IResult, new()

我正在尝试“简化”一些动态通用抽象类,其中TParams对于每个继承的泛型类是相同的,但对于Result来说是相同的。

我尝试过这样的事情:

public abstract class SqlQueryDynamicGetCbmClients<TParams> : 
SqlQueryDynamicTmpl<SqlQueryDynamicGetCbmClients<TParams>
    ,TParams,SqlQueryDynamicGetCbmClients<TParams>.Result>,IParams
    where TParams:class, SqlQueryDynamicGetCbmClients<TParams>.IParams

但信息出错:

  

严重级代码描述项目文件行抑制状态   错误CS0310'SqlQueryDynamicGetCbmClients'必须是具有公共无参数构造函数的非抽象类型,才能在泛型类型或方法中将其用作参数'TSelf'

有人知道我应该怎么做吗?

0 个答案:

没有答案
相关问题