Exemple #1
0
        static void TestWriteDataWarpper()
        {
            DemoDbContext remoteDbContext = new DemoDbContext(AdoHelper.CreateHelper("DemoDB"));

            //删除数据,必须通过DbContext 来处理,详细参见 解决方案说明.txt 文件的数据同步说明
            using (IWriteDataWarpper warpper = WriteDataWarpperFactory.Create(remoteDbContext))
            {
                UserEntity entity = new UserEntity();
                entity.UID = 100;
                remoteDbContext.Remove <UserEntity>(entity);
            }
        }
Exemple #2
0
        static void InitData(string dbName, string prjId)
        {
            DemoDbContext context = new DemoDbContext(AdoHelper.CreateHelper(dbName));
            //分类ID

            int delId = 0;

            for (int i = 0; i < 100; i++)
            {
                TestEntity test = new TestEntity();
                test.Name           = "Name" + i;
                test.AtTime         = DateTime.Now;
                test.Classification = prjId;
                context.Add(test);

                UserEntity user = new UserEntity();
                user.Name     = "User" + i;
                user.Sex      = false;
                user.Height   = 1.6f + i / 10;
                user.Birthday = new DateTime(1990, 1, 1).AddDays(i);
                context.Add(user);

                if (i == 50)
                {
                    delId = test.ID;
                }
            }
            //删除数据,确保被删除的ID写入到ID删除记录表中
            using (IWriteDataWarpper warpper = WriteDataWarpperFactory.Create(context))
            {
                context.Remove(new TestEntity()
                {
                    ID = delId
                });
                context.Remove(new UserEntity()
                {
                    UID = delId
                });
            }
        }