Example #1
0
        public static void Sample_ReadOracle_WriteCsv()
        {
            string sampleDataPath = @"..\..\Samples\";
            var    watch          = new Stopwatch();

            using (var reader = new DbAdapter())
            {
                reader.ConnectionInfo = new OracleNativeDbConnectionInfo()
                {
                    Database = "TESTDB01",
                    UserName = "******",
                    Password = "******",
                    Host     = "COMPUTER01"
                };
                reader.TableName = "TB_DATA";
                reader.Connect();

                using (var writer = new CsvAdapter())
                {
                    writer.FileName = Path.Combine(sampleDataPath, "TB_DATA.csv");

                    watch.Start();
                    int lineCount = 0;

                    reader.ReadData(30)
                    .ForEach(x =>
                    {
                        Console.WriteLine("Tablename=" + x.TableName + ", Count=" + x.Rows.Count);
                        lineCount += x.Rows.Count;
                    })
                    .Do(x => writer.WriteData(x, false));

                    watch.Stop();
                    Console.WriteLine("lineCount=" + lineCount + ", Time=" + watch.Elapsed);
                    Console.ReadLine();
                }

                reader.Disconnect();
            }
        }