Ejemplo n.º 1
0
        private object BuildDelegate <T>(MetadataForModel metadata)
        {
            var dynamicMethod = GetDynamicMethod <T>();

            using (var il = new GroboIL(dynamicMethod))
            {
                il.Ldarg(0);
                il.Callnonvirt(GetStartRowMethod());

                foreach (var emitInfo in metadata.EmitInfos)
                {
                    il.Ldarg(0);
                    il.Ldarg(1);
                    il.Callnonvirt(emitInfo.Getter);
                    if (emitInfo.PostgresType != null)
                    {
                        il.Ldc_I4((int)emitInfo.PostgresType.Value);
                    }
                    il.Callnonvirt(emitInfo.WriteMethod);
                }

                il.Ret();
            }

            return(dynamicMethod.CreateDelegate(typeof(Action <NpgsqlBinaryImporter, T>)));
        }
Ejemplo n.º 2
0
        public string GetSql(MetadataForModel metadata)
        {
            var colNames = metadata.EmitInfos.Select(x => x.PostgresName).ToArray();

            return($"COPY {metadata.TableName} ({string.Join(',', colNames)})" +
                   $" FROM STDIN (FORMAT BINARY)");
        }
Ejemplo n.º 3
0
 public Action <NpgsqlBinaryImporter, T> GetDelegate <T>(MetadataForModel metadata)
 {
     return((Action <NpgsqlBinaryImporter, T>)BuildDelegate <T>(metadata));
 }