protected void btnTableReCreate_Click(object sender, EventArgs e) { if (Membership.ValidateUser(this.User.Identity.Name, this.ed_Passwrod.Text)) { switch (this.ed_TableName.Text) { case "Suzhi": DbEntry.DropAndCreate(typeof(Suzhi)); Succeed("综合素质表Suzhi重建成功"); break; case "Bmdxx": DbEntry.DropAndCreate(typeof(Bmdxx)); Succeed("报名点信息表Bmdxx表重建成功"); break; default: break; } } else { Fail("密码错"); } }
protected override void OnSetUp() { base.OnSetUp(); DbEntry.DropAndCreate(typeof(Cls1)); DbEntry.DropAndCreate(typeof(Cls2)); DbEntry.DropAndCreate(typeof(Cls3)); DbEntry.DropAndCreate(typeof(Cls4)); DbEntry.DropAndCreate(typeof(Cls5)); DbEntry.DropAndCreate(typeof(OverSave)); DbEntry.DropAndCreate(typeof(OverSave2)); DbEntry.DropAndCreate(typeof(OverSave3)); DbEntry.DropAndCreate(typeof(OverSave4)); }
public void TestCreateTable() { DbEntry.DropAndCreate(typeof(BelongsMore)); ArticleMore a = ArticleMore.FindById(1); Assert.AreEqual(0, a.Bms.Count); a.Bms.Add(new BelongsMore { Name = "mytest" }); a.Save(); a = ArticleMore.FindById(1); Assert.AreEqual(1, a.Bms.Count); Assert.AreEqual("mytest", a.Bms[0].Name); }
public void Test10() { DbEntry.DropAndCreate(typeof(TableC)); DbEntry.DropAndCreate(typeof(TableD)); DbEntry.CreateCrossTable(typeof(TableC), typeof(TableD)); var t1 = new TableC { Title = "Article1" }; t1.Save(); var t3 = new TableD { Name = "Tag1" }; t3.Save(); var t2 = TableC.FindOne(p => p.Id == 1); t2.TD.Add(t3); t2.Save(); //Begin Remove var t4 = TableC.FindById(1); Assert.AreEqual(1, t4.TD.Count); var t5 = TableD.FindById(1); Assert.AreEqual(1, t5.TC.Count); bool b = t4.TD.Remove(t5); Assert.IsTrue(b); t4.Save(); //here b= false and can't trace the delete sql bool b2 = t5.TC.Remove(t4); Assert.IsTrue(b2); t5.Save(); //here b2= false and can't trace the delete sql }
public void TestX() { DbEntry.DropAndCreate(typeof(TableA)); DbEntry.DropAndCreate(typeof(TableB)); var t1 = new TableA { Name = "TestName1" }; t1.Save(); var t2 = TableA.FindById(1); var t3 = new TableB { Url = "TestUrl1", TB = t2 }; t3.Validate(); t3.Save(); }
public void TestSoftDeleteOnlyWorksForTheRightOne() { DbEntry.DropAndCreate(typeof(Test)); var t = new Test { Nome = "myName" }; t.Save(); t = new Test { Nome = "myName2" }; t.Save(); t = Test.FindById(1); t.Delete(); t = Test.FindById(1); Assert.IsNull(t); t = Test.FindById(2); Assert.IsNotNull(t); Assert.AreEqual("myName2", t.Nome); }