Dictionary<父类, WhereClip<父类>> dic = new Dictionary<BaseEntity, WhereClip<BaseEntity>>();            子类 admin = new 子类();
                       WhereClip<子类> adminwhere = new WhereClip<子类>(a => a.User_ID == 67 );
            dic.Add(admin, adminwhere);--报错:与最匹配的参数。。上面这样是无法添加的,那位大哥有不有办法搞定。 dic.Add(admin, null);--这样是行的也就是说泛型类。

解决方案 »

  1.   

    创建时用的是 BaseEntity 
    你后面的所谓子类和BaseEntity 啥关系
      

  2.   

    WhereClip<子类>和WhereClip<父类>就不是一个类型,你想让程序怎么帮你转换?
      

  3.   

    直接把T换成BaseEntity试试,你这样T继承BaseEntity,和你那个子类完全没有关系
      

  4.   


    我这样其实就是把T 变成了 baseEntity
      

  5.   

    其实我这样想不管什么泛型啊 所以类型基类 ObjectDictionary<父类, WhereClip<Object>> dic = new Dictionary<BaseEntity, WhereClip<Object>>();  子类 admin = new 子类();
          WhereClip<子类> adminwhere = new WhereClip<子类>(a => a.User_ID == 67 );
      dic.Add(admin, adminwhere);
      

  6.   

    你搞错了,WhereClip<子类>和 WhereClip<父类>是两个类型,和里面的T的类型是没有关系的,刚才我说那样是错误的
      

  7.   

    最终解决方案:
    Dictionary<父类,Object> dic = new Dictionary<BaseEntity, Object>();  子类 admin = new 子类();
          WhereClip<子类> adminwhere = new WhereClip<子类>(a => a.User_ID == 67 );
      dic.Add(admin, adminwhere);
      

  8.   

    定一个接口   如Dictionary<父类,接口> dic = new Dictionary<BaseEntity, 子类>();