예제 #1
0
        static void InsertTest()
        {
            MssqlInsert insert = new MssqlInsert();

            string[] fields = { "ID", "UserName", "Gender", "Phone", "LastModifyTime" };
            insert.TableName = "Customers";
            DataTable table = new DataTable();

            table.Columns.Add("ID");
            table.Columns.Add("UserName");
            table.Columns.Add("Gender");
            table.Columns.Add("Phone");
            table.Columns.Add("LastModifyTime");
            Stopwatch watch = new Stopwatch();

            watch.Start();
            for (int i = 0; i < 10; i++)
            {
                //object[] values = { Guid.NewGuid().ToString("N"), "李进", 1, "13856986236", DateTime.Now };
                //insert.InsertObject(fields, values);
                //Customers cus = new Customers();
                //cus.ID = Guid.NewGuid().ToString("N");
                //cus.UserName = "******";
                //cus.Phone = null;
                //cus.Gender = 0;
                //cus.LastModifyTime = DateTime.Now;
                //insert.InsertObject<Customers>(cus);
                //table.Clear();
                //for (int j = 0; j < 100000; j++)
                //{
                //    DataRow dr = table.NewRow();
                //    dr["ID"] = Guid.NewGuid().ToString("N");
                //    dr["UserName"] = "******";
                //    dr["Gender"] = 1;
                //    dr["Phone"] = "13800138000";
                //    dr["LastModifyTime"] = DateTime.Now;

                //    table.Rows.Add(dr);
                //}
                //insert.InsertObject(table);
            }
            insert.SaveChange();
            watch.Stop();
            Console.WriteLine(watch.Elapsed.Milliseconds);
        }
예제 #2
0
        /**
         * @ 新增项
         * */
        public override bool Add(IEnumerable <PermitData> menu)
        {
            bool succeess = true;

            if (menu == null)
            {
                return(succeess);
            }

            MssqlInsert insert = new MssqlInsert(TableName);

            foreach (var item in menu)
            {
                item.ID = Guid.NewGuid().ToString("N");
                insert.InsertObject <PermitData>(item);
            }
            insert.SaveChange();

            return(succeess);
        }
예제 #3
0
        /**
         * @ 新增项
         * */
        public override bool Add(IEnumerable <RoleDetail> menu)
        {
            bool succeess = true;

            if (menu == null)
            {
                return(succeess);
            }

            MssqlInsert insert = new MssqlInsert(TableName);

            foreach (var item in menu)
            {
                if (item.Detail_ID.IsNullOrEmpty() || item.Role_ID.IsNullOrEmpty() || item.Type.IsEnum <DetailType, int>() == false)
                {
                    throw new ArgumentNullException("不能将空数据插入 RoleDetail 表中");
                }
                insert.InsertObject <RoleDetail>(item);
            }
            insert.SaveChange();

            return(succeess);
        }