public static class MrpPraFindSuggestionForSelectionFactory
    {
        public static IMrpPraFindSuggestionForSelection<T> Create<T>() where T : Ufida.T.EAP.Domains.DTO, Ufida.T.MP.DTO.ITransferDTO;
    }
public class BM
{
        public IList<K> FindForSelection<K>(string selectedFields, string whereOql, IDictionary<string, object> otherconditions)
        {
            IMrpPraFindSuggestionForSelection<K> findforSelection = MrpPraFindSuggestionForSelectionFactory.Create<K>();
            return findforSelection.FindForSelection(selectedFields, whereOql, otherconditions);        }
}但是编译的时候发生错误;
不能将类型“K”用作泛型类型或方法“MrpPraFindSuggestionForSelectionFactory.Create<T>()”中的类型形参“T”。没有从“K”到“Ufida.T.EAP.Domains.DTO”的装箱转换或类型形参转换。 想问一下这个问题应该怎么解决阿?

解决方案 »

  1.   

    T实现的是where T : Ufida.T.EAP.Domains.DTO, Ufida.T.MP.DTO.ITransferDTO;
    这个k,跟T有没有关系?K这个类型有没有定义?
      

  2.   

    public IList<K> FindForSelection<K>(string selectedFields, string whereOql, IDictionary<string, object> otherconditions) where K : Ufida.T.EAP.Domains.DTO, Ufida.T.MP.DTO.ITransferDTO
    {
    IMrpPraFindSuggestionForSelection<K> findforSelection = MrpPraFindSuggestionForSelectionFactory.Create<K>();
    return findforSelection.FindForSelection(selectedFields, whereOql, otherconditions);
    }
      

  3.   

    where 只允许泛型继承的类型
      

  4.   

    这样好像不行,虽然都实现了这两个接口,但是这两个类之间还是没有关系,应该让K继承与T,或者在K和T之间重载一个隐式转换运算符吧