Beispiel #1
0
        private DynamicMethod CompileDynamicMethod(DynamicTypeGenerator gen, SqlExpression expression, Type elementType)
        {
            Type          objectReaderType = typeof(ObjectMaterializer <>).MakeGenericType(this.dataReaderType);
            DynamicMethod dm = new DynamicMethod(
                "Read_" + elementType.Name,
                elementType,
                new Type[] { objectReaderType },
                true
                );

            gen.GenerateBody(dm.GetILGenerator(), expression);
            return(dm);
        }
Beispiel #2
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();
        }