解决方案 »

  1.   

    提醒一下,上面的你都已经实例化了,还用泛型再实例化一遍?写错了。另外,看代码你们用到的领域驱动,但是“ExportDataByTableNameQuery”看出,你们还处于数据库驱动的阶段。写代码别想着主表,从表,视图 and so on,要想着对象,对象,对象。
      

  2.   

    这是一个demo,实例化的那句不用管,他有别的用处,现在是要把类型当作泛型的参数怎么传过去,就是Type.MakeGenericType这个方法怎么用?还有怎么看出我是数据库驱动的啊?
      

  3.   

    Type[] typeArgs = { typeof(string), typeof(Test) };Type constructed = generic.MakeGenericType(typeArgs);
      

  4.   


    这是msdn上的,能结合我上面的代码给一份吗?
      

  5.   

    定义泛型类 public class Class1<T>
    {
         void A()  
      { 
       }
         list<T>(T t)  
     {   
     }}
    调用,Class1<string>.A()     , Class1<int>.A()  
      

  6.   

    public static TPrototype Resolve<TPrototype, TDefault>(string resolverName = null)
                where TPrototype : class
                where TDefault : TPrototype, new()
            {
                if (ObjectManagerConfigurations.TypeMapping != null) 
                {
                    IDictionary<string, Type> resolvers;
                    if (ObjectManagerConfigurations.TypeMapping.TryGetValue(typeof(TPrototype), out resolvers))
                    {
                        Type type;
                        resolverName = (resolverName==null) ? string.Empty : resolverName.Trim();
                        if (resolvers.TryGetValue(resolverName, out type))
                        {
                            try
                            {
                                return Activator.CreateInstance(type) as TPrototype;
                            }
                            catch (Exception ex)
                            {
                                Trace.WriteLine(string.Format("failed to create instance of type \"{0}\". Exception:{1}",type.FullName, ex.ToString()));
                            }
                        }
                    }
                }
                return new TDefault();
            }