public override List <ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo cxInfo, AssemblyName assemblyToBuild, ref string nameSpace, ref string typeName)
        {
            var fileName  = Path.GetFileName(assemblyToBuild.CodeBase);
            var directory = Path.GetDirectoryName(assemblyToBuild.CodeBase);

            var assemblyBuilder = Thread.GetDomain().DefineDynamicAssembly(assemblyToBuild, AssemblyBuilderAccess.RunAndSave, directory);
            var moduleBuilder   = assemblyBuilder.DefineDynamicModule(assemblyToBuild.Name, fileName);

            var dataContextTypeBuilder = moduleBuilder.DefineType(string.Format("{0}.{1}", nameSpace, typeName), TypeAttributes.Public, typeof(TypedDataContextBase));

            var explorerItems = new List <ExplorerItem>();

            using (var connection = GetIDbConnection(cxInfo))
            {
                connection.Open();

                var manager = new DatabaseObjectProviderManager(cxInfo, moduleBuilder, connection, nameSpace);
                foreach (var provider in manager.DatabaseObjectProviders.OrderBy(x => x.Priority))
                {
                    explorerItems.Add(provider.EmitCodeAndGetExplorerItemTree(dataContextTypeBuilder));
                }
            }

            // fetch the base constructor which shall be called by the new constructor
            var baseConstructor = typeof(TypedDataContextBase).GetConstructor(new[] { typeof(string), typeof(string) });

            // create the typed data context's constructor
            var dataContextConstructor = dataContextTypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new[] { typeof(string), typeof(string) });
            var ilGenerator            = dataContextConstructor.GetILGenerator();

            ilGenerator.Emit(OpCodes.Ldarg_0);
            ilGenerator.Emit(OpCodes.Ldarg_1);
            ilGenerator.Emit(OpCodes.Ldarg_2);

            // call the base constructor
            ilGenerator.Emit(OpCodes.Call, baseConstructor);

            ilGenerator.Emit(OpCodes.Ret);

            dataContextTypeBuilder.CreateType();

            assemblyBuilder.Save(fileName);

            return(explorerItems);
        }
      public override List<ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo cxInfo, AssemblyName assemblyToBuild, ref string nameSpace, ref string typeName)
      {
         var fileName = Path.GetFileName(assemblyToBuild.CodeBase);
         var directory = Path.GetDirectoryName(assemblyToBuild.CodeBase);

         var assemblyBuilder = Thread.GetDomain().DefineDynamicAssembly(assemblyToBuild, AssemblyBuilderAccess.RunAndSave, directory);
         var moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyToBuild.Name, fileName);

         var dataContextTypeBuilder = moduleBuilder.DefineType(string.Format("{0}.{1}", nameSpace, typeName), TypeAttributes.Public, typeof(TypedDataContextBase));

         var explorerItems = new List<ExplorerItem>();

         using (var connection = GetIDbConnection(cxInfo))
         {
            connection.Open();

            var manager = new DatabaseObjectProviderManager(cxInfo, moduleBuilder, connection, nameSpace);
            foreach (var provider in manager.DatabaseObjectProviders.OrderBy(x => x.Priority))
            {
                 explorerItems.Add(provider.EmitCodeAndGetExplorerItemTree(dataContextTypeBuilder));
            }
         }

         // fetch the base constructor which shall be called by the new constructor
         var baseConstructor = typeof(TypedDataContextBase).GetConstructor(new[] { typeof(string), typeof(string) });

         // create the typed data context's constructor
         var dataContextConstructor = dataContextTypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new[] { typeof(string), typeof(string) });
         var ilGenerator = dataContextConstructor.GetILGenerator();

         ilGenerator.Emit(OpCodes.Ldarg_0);
         ilGenerator.Emit(OpCodes.Ldarg_1);
         ilGenerator.Emit(OpCodes.Ldarg_2);

         // call the base constructor
         ilGenerator.Emit(OpCodes.Call, baseConstructor);

         ilGenerator.Emit(OpCodes.Ret);

         dataContextTypeBuilder.CreateType();

         assemblyBuilder.Save(fileName);

         return explorerItems;
      }