Example #1
0
        private void CompileCapturedMethod(DynamicTypeGenerator gen, SqlExpression expression, Type elementType)
        {
            TypeBuilder   tb = ObjectReaderCompiler.CaptureModule.DefineType("reader_type_" + ObjectReaderCompiler.GetNextId());
            MethodBuilder mb = tb.DefineMethod(
                "Read_" + elementType.Name,
                MethodAttributes.Static | MethodAttributes.Public,
                CallingConventions.Standard,
                elementType,
                new Type[] { typeof(ObjectMaterializer <>).MakeGenericType(this.dataReaderType) }
                );

            gen.GenerateBody(mb.GetILGenerator(), (SqlExpression)SqlDuplicator.Copy(expression));
            tb.CreateType();
        }
		internal DynamicTypeGenerator(ObjectReaderCompiler compiler, Type elementType)
		{
			this.compiler = compiler;
			this.elementType = elementType;
			this.associationSubQueries = new Dictionary<MetaAssociation, int>();
		}