批量获取sql后再执行写入操作
大石头 编写于 2020-11-08 19:09:05
FeiXian
using System;
using System.Collections.Generic;
//using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FeiXian.Client;
//using FeiXian.Client.Entity;
using NewLife.Log;
using XCode.Common;
using XCode.DataAccessLayer;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            XTrace.UseConsole();

            try
            {
                Test1();
            }
            catch (Exception ex)
            {
                XTrace.WriteException(ex.GetTrue());
            }

            Console.WriteLine("OK!");
            Console.ReadKey();
        }

        static void Test1()
        {
            //SQLiteLog.Enabled = true;
            //SQLiteLog.Initialize();
            //SQLiteLog.AddDefaultHandler();
            //SQLiteLog.Log += SQLiteLog_Log;

            var cfg = Setting.Current;
            cfg.BatchSize = 1000;
            cfg.Threads = 4;
            cfg.UseSql = true;
            cfg.Times = 100000;

            //var Dal = DAL.Create("SQLite");
            //var Factory = DemoEntity.Meta.Factory;

            //Factory.Table.ConnName = Dal.ConnName;
            //Factory.ConnName = Dal.ConnName;

            //var ds = new DataSimulate<DemoEntity>
            //{
            //    Log = XTrace.Log,
            //    BatchSize = cfg.BatchSize,
            //    Threads = cfg.Threads,
            //    UseSql = cfg.UseSql
            //};

            //ds.Run(cfg.Times);
        }

        //private static void SQLiteLog_Log(Object sender, LogEventArgs e)
        //{
        //    XTrace.WriteLine("{0} {1}", e.ErrorCode, e.Message);
        //}
    }
}