【发布时间】:2014-06-26 12:26:07
【问题描述】:
我在课堂上有这个方法:
member this.GetDbSet<'TEntity, 'TDTO, 'TKey when 'TKey :> IEquatable<'TKey> and 'TEntity :> IEntity<'TKey> and 'TEntity : not struct and 'TDTO :> IDTO<'TKey> and 'TEntity : equality and 'TEntity : null and 'TDTO : equality and 'TDTO : null and 'TKey : equality>(repository : BaseRepository<'TEntity, 'TDTO, 'TKey>) =
repository.DbSetFuncGetter().Invoke(uow.Context())
但是当我构建项目时,我得到了这个错误
This code is not sufficiently generic. The type variable 'TEntity when 'TEntity :> IEntity<'TKey> and 'TEntity : not struct and 'TEntity : equality and 'TEntity : null and 'TKey :> IEquatable<'TKey> and 'TKey : equality could not be generalized because it would escape its scope.
但是所有的限制都在那里。我错过了什么吗?
编辑:
如果您需要更多代码:
这是开源项目
【问题讨论】:
标签: .net generics f# constraints f#-3.0