Пример #1
0
        static void Test13()
        {
            var file = @"E:\BaiduYunDownload\xiaomi.db";
            var file2 = Path.ChangeExtension(file, "sqlite");
            DAL.AddConnStr("src", "Data Source=" + file, null, "sqlite");
            DAL.AddConnStr("des", "Data Source=" + file2, null, "sqlite");

            if (!File.Exists(file2))
            {
                var et = new EntityTransform();
                et.SrcConn = "src";
                et.DesConn = "des";
                //et.PartialTableNames.Add("xiaomi");
                //et.PartialCount = 1000000;

                et.Transform();
            }

            var sw = new Stopwatch();

            var dal = DAL.Create("src");
            var eop = dal.CreateOperate(dal.Tables[0].TableName);
            sw.Start();
            var count = eop.Count;
            sw.Stop();
            XTrace.WriteLine("{0} 耗时 {1}ms", count, sw.ElapsedMilliseconds);
            sw.Reset(); sw.Start();
            count = eop.FindCount();
            sw.Stop();
            XTrace.WriteLine("{0} 耗时 {1}ms", count, sw.ElapsedMilliseconds);

            var entity = eop.Create();
            entity["username"] = "******";
            entity.Save();
            count = eop.FindCount();
            Console.WriteLine(count);

            entity.Delete();
            count = eop.FindCount();
            Console.WriteLine(count);
        }
Пример #2
0
        public static int CopyDbData(string origConn,string origDb, string desConn,string desDb ,bool isAllowIndentity = true,List<string > tables = null )
        {
            //DAL.AddConnStr("xxgk", "Data Source=192.168.1.21;Initial Catalog=信息公开;user id=sa;password=Pass@word", null, "mssql");
            //var dal = DAL.Create("xxgk"); DAL.AddConnStr("xxgk2", "Data Source=XXGK.db;Version=3;", null, "sqlite"); 
            //File.Delete("XXGK.db");
            //DAL.ShowSQL = false; 
            string origName = "Origin";
            string desName = "Des";
            DAL.AddConnStr(origName , origConn, null, origDb);
            var dal = DAL.Create("Origin");
            DAL.AddConnStr(desName , desConn, null, desDb);

            var etf = new EntityTransform();
            etf.SrcConn = origName;
            etf.DesConn = desName;
            etf.AllowInsertIdentity = true;
            if (tables !=null ) etf.TableNames = tables;
            else etf.TableNames = DAL.Create(origName).Tables.Select(n => n.Name).ToList();           
            //etf.OnTransformTable += (s, e) => { if (e.Arg.Name == "")e.Arg = null; };
            int rs = -2;
            try
            {
                rs = etf.Transform();
                Console.WriteLine("共转移:{0}", rs);
                return rs;
            }
            catch (Exception err)
            {
                rs = -1;
                throw new Exception(err.Message );
            }
        }