public void Test2() { Model m = OrmUtils.Model("User"); Assert.IsNotNull(m); Assert.AreEqual <string>(m.Table, "t_user"); }
public void Test1() { bool ret = OrmUtils.Model("Animal").TryCreateTable(true); Assert.IsTrue(ret); dynamic newanimal = ModelObject.New("Animal"); newanimal.Name = "panda"; newanimal.Feature = new DynamicObjectExt(); newanimal.Feature.Food = "竹子"; newanimal.Feature.Color = "黑白"; newanimal.Feature.Life = 30; bool ret2 = OrmUtils.Model("Animal").SetValues(newanimal).Save(); Assert.IsTrue(ret2); dynamic result = OrmUtils.Model("Animal").Equals("Name", "panda").QueryFirst(); Assert.IsNotNull(result); Assert.AreNotEqual("panda", result.Name); Assert.AreEqual("PANDA", result.Name); Assert.AreEqual("黑白", result.Feature.Color); Assert.AreEqual(30, result.Feature.Life); Assert.AreEqual(DateTime.Now.ToString("yyyy-MM-dd"), result.DiscDate); }
public void Test4() { dynamic neworg = OrmUtils.Model("Org").NewObject(); neworg.Code = "Trans_Org"; neworg.Name = "事务测试-机构01"; dynamic newuser = OrmUtils.Model("User").NewObject(); newuser.Name = "事务测试-用户01"; int trans = OrmUtils.GetTransaction(); try { OrmUtils.Model("Org").SetValues(neworg).Save(trans); OrmUtils.Model("User").SetValues(newuser).Save(trans); OrmUtils.CommitTransaction(trans); } catch { OrmUtils.RollbackTransaction(trans); } List <dynamic> result = OrmUtils.Model("Org").Equals("Name", "事务测试-机构01").Query(); Assert.AreEqual <int>(result.Count, 1); List <dynamic> result2 = OrmUtils.Model("User").Equals("Name", "事务测试-用户01").Query(); Assert.AreEqual <int>(result2.Count, 1); }
public void Test4() { List <dynamic> result = OrmUtils.Model("User").NotIn("Name", "User1", "User5", "User32").AscendingSort("Name").Query(); Assert.AreEqual <int>(result.Count, 9997); Assert.AreEqual <string>(result[0].Name, "User10"); }
public void Test3() { OrmUtils.Model("Org").Equals("Name", "XX科技").SetValue("Name", "YY科技").Update(); List <dynamic> result = OrmUtils.Model("Org").Equals("Name", "YY科技").Top(1).Query(); Assert.IsTrue(result[0].CreateTime.ToString("G") == result[0].UpdateTime.ToString("G")); }
public void Test19() { List <dynamic> result = OrmUtils.Model("user").PageSize(1).PageIndex(1).Query(); List <dynamic> result2 = OrmUtils.Model("user").Top(1).Query(); Assert.AreEqual(result.Count, result2.Count); }
public void Test7() { dynamic result = OrmUtils.Model("User") .GetValue(AggregateType.AVG, "Age") .QueryFirst(); Assert.IsTrue(15 == result.Age); }
public void Test4() { dynamic result = OrmUtils.Model("User") .Equals("Age", 18) .GetValue(AggregateType.COUNT, "Id") .QueryFirst(); Assert.AreEqual(2, result.Id); }
public void Test3() { List <dynamic> result = OrmUtils.Model("User") .GetValue(AggregateType.COUNT, AggregateType.DISTINCT, "Age", "Count") .Query(); Assert.AreEqual(1, result.Count); Assert.AreEqual(3, result[0].Count); }
public void Test5() { List <dynamic> result = OrmUtils.Model("User").In("Name", "wangxm", "huxinyue").Query(); Assert.AreEqual(result.Count, 2); List <dynamic> result2 = OrmUtils.Model("User").In("Name", "").Query(); Assert.AreEqual(result2.Count, 0); }
public void Test4() { dynamic result = OrmUtils.Model("Shopping") .Equals("Code", "iPhone 12") .GetValue(FunctionType.DATE, "CreateTime", "CDate") .QueryFirst(); Assert.IsNotNull(result); Assert.AreEqual(DateTime.Now.ToString("yyyy-MM-dd"), result.CDate); }
public void Test5() { dynamic neworg = ModelObject.New("Org"); neworg.Code = "YYTech"; neworg.Name = "YY科技"; bool ret = OrmUtils.Model("Org").SetValues(neworg).Save(); Assert.IsTrue(ret); }
public void Test6() { List <dynamic> orgList = OrmUtils.Model("Org").Equals("Name", "YY科技").Query(); dynamic newuser = ModelObject.New("User"); newuser.Name = "huxy"; newuser.Org = orgList[0].Code; bool ret = OrmUtils.Model("User").SetValues(newuser).Save(); Assert.IsTrue(ret); }
public void Test2() { dynamic newuser = ModelObject.New("User"); newuser.Name = "wangxm"; newuser.Age = 18; newuser.IsAdmin = true; bool ret = OrmUtils.Model("User").SetValues(newuser).Save(); Assert.IsTrue(ret); }
public void Test2() { dynamic newshopping = ModelObject.New("Shopping"); newshopping.Code = "iPhone 12"; newshopping.Name = "苹果12手机"; newshopping.Order = "S202100812085255000"; bool ret = OrmUtils.Model("Shopping").SetValues(newshopping).Save(); Assert.IsTrue(ret); }
public void Test6() { List <dynamic> result = OrmUtils.Model("User").Equals("Name", "huxinyue").Top(1).Query(); Assert.AreEqual(result.Count, 1); Assert.IsInstanceOfType(result[0].Name, typeof(string)); Assert.IsInstanceOfType(result[0].Age, typeof(UInt16)); Assert.IsInstanceOfType(result[0].Birthday, typeof(DateTime)); Assert.IsInstanceOfType(result[0].Deposit, typeof(decimal)); Assert.IsInstanceOfType(result[0].IsAdmin, typeof(bool)); }
public void Test5() { List <dynamic> result = OrmUtils.Model("User") .GroupBy("Age") .GetValue(AggregateType.COUNT, "Id", "Id_Count") .GetValue("Age") .DescendingSort("Id_Count") .Top(5) .Query(); Assert.AreEqual <int>(result.Count, 5); }
public void Test6() { Thread.Sleep(3000); bool ret = OrmUtils.Model("User").Equals("Name", "wangxm").SetValue("Age", 20).Update(); Assert.IsTrue(ret); List <dynamic> result = OrmUtils.Model("User").Equals("Name", "wangxm").Top(1).Query(); Assert.IsTrue(result[0].UpdateTime > result[0].CreateTime); }
public void Test4() { dynamic newuser = ModelObject.New("User"); newuser.Name = "huxinyue"; newuser.Age = 11; newuser.Birthday = new DateTime(1987, 4, 26); newuser.Deposit = 99999999; newuser.IsAdmin = true; bool ret = OrmUtils.Model("User").SetValues(newuser).Save(); Assert.IsTrue(ret); }
public void Test6() { dynamic newuser = ModelObject.New("User"); newuser.Name = "jishuwen"; newuser.Age = 18; newuser.Birthday = new DateTime(1947, 1, 16); newuser.Deposit = 10000000.58; newuser.IsAdmin = true; bool ret = OrmUtils.Model("User").SetValues(newuser).Save(); Assert.IsTrue(ret); }
public void Test2() { dynamic newuser = ModelObject.New("User"); newuser.Name = "wangxm"; newuser.Age = 18; newuser.Birthday = new DateTime(1980, 6, 14); newuser.Deposit = 10000000.58; newuser.IsAdmin = null; bool ret = OrmUtils.Model("User").SetValues(newuser).Save(); Assert.IsTrue(ret); }
public void Test2() { dynamic neworg = ModelObject.New("Org"); neworg.Code = "XXTech"; neworg.Name = "XX科技"; bool ret = OrmUtils.Model("Org").SetValues(neworg).Save(); Assert.IsTrue(ret); List <dynamic> result = OrmUtils.Model("Org").Equals("Name", "XX科技").Top(1).Query(); Assert.IsTrue(result[0].CreateTime.ToString("G") == result[0].UpdateTime.ToString("G")); }
public void Test3() { try { bool ret = OrmUtils.Model("User").SetValue("Name", "wangxm").Save(); Assert.IsFalse(ret); } catch (Exception exp) { Assert.IsTrue(exp.Message.ToUpper().Contains("UNIQUE") || exp.Message.ToUpper().Contains("DUPLICATE") || exp.Message.ToUpper().Contains("ORA-03115")); } }
public void Test4() { List <dynamic> result = OrmUtils.Model("Org").Equals("Name", "YY科技").Top(1).Query(); dynamic newuser = ModelObject.New("User"); newuser.Name = "wangxm"; newuser.Age = 18; newuser.Org = result[0].Code; newuser.Deposit = 99999999; newuser.IsAdmin = true; bool ret = OrmUtils.Model("User").SetValues(newuser).Save(); Assert.IsTrue(ret); }
public void Test2() { Random r = new Random(); for (int i = 0; i < 10000; i++) { dynamic newuser = ModelObject.New("User"); newuser.Name = "User" + (i + 1); newuser.Age = r.Next(18, 150); newuser.Birthday = new DateTime(1980, 1, 16); newuser.Deposit = r.Next(10000000, 999999999); newuser.IsAdmin = true; OrmUtils.Model("User").SetValues(newuser).Save(); } }
public void Test7() { dynamic newuser = ModelObject.New("User"); newuser.Name = "wangss"; newuser.Age = 18; newuser.Birthday = new DateTime(1947, 10, 1); newuser.Deposit = 10000000.58; newuser.IsAdmin = true; bool ret = OrmUtils.Model("User").SetValues(newuser).Save(); Assert.IsTrue(ret); Assert.IsTrue(OrmUtils.Model("User").Count() == 3); Assert.IsTrue(OrmUtils.Model("User").GetValue(AggregateType.DISTINCT, "Age").Count() == 2); }
public void Test2() { dynamic newuser = ModelObject.New("User"); newuser.Name = "wangxm"; newuser.Age = 30; newuser.Birthday = new DateTime(1992, 6, 14); newuser.Deposit = 10000000.58; newuser.IsAdmin = null; bool ret = OrmUtils.Model("User").SetValues(newuser).Save(); Assert.IsTrue(ret); dynamic newuser2 = ModelObject.New("User"); newuser2.Name = "huxy"; newuser2.Age = 23; newuser2.Birthday = new DateTime(1999, 4, 29); newuser2.Deposit = 10000000.58; newuser2.IsAdmin = null; bool ret2 = OrmUtils.Model("User").SetValues(newuser2).Save(); Assert.IsTrue(ret2); dynamic newuser3 = ModelObject.New("User"); newuser3.Name = "jisw"; newuser3.Age = 50; newuser3.Birthday = new DateTime(1972, 1, 16); newuser3.Deposit = 10000000.58; newuser3.IsAdmin = null; bool ret3 = OrmUtils.Model("User").SetValues(newuser3).Save(); Assert.IsTrue(ret3); dynamic newuser4 = ModelObject.New("User"); newuser4.Name = "wangss"; newuser4.Age = 50; newuser4.Birthday = new DateTime(1972, 10, 1); newuser4.Deposit = 10000000.58; newuser4.IsAdmin = null; bool ret4 = OrmUtils.Model("User").SetValues(newuser4).Save(); Assert.IsTrue(ret4); }
public void Test4() { bool ret; try { dynamic newuser = ModelObject.New("User"); newuser.Name = "wangxm"; newuser.Age = 250; newuser.Birthday = new DateTime(1980, 6, 14); newuser.Deposit = 10000000.58; newuser.IsAdmin = true; ret = OrmUtils.Model("User").SetValues(newuser).Save(); } catch { ret = false; } Assert.IsFalse(ret); }
public void Test5() { dynamic newshopping = ModelObject.New("Shopping"); newshopping.Code = "iPhone 12"; newshopping.Name = "苹果手机12"; newshopping.Order = "S202100812085255000"; bool ret = OrmUtils.Model("Shopping").SetValues(newshopping).Save(); Assert.IsTrue(ret); List <dynamic> result = OrmUtils.Model("Shopping") .GetValue(FunctionType.DATE, "CreateTime") .GetValue("Code") .GetValue(AggregateType.COUNT, "Id", "Count") .GroupBy(FunctionType.DATE, "CreateTime") .GroupBy("Code") .Query(); Assert.AreEqual(1, result.Count); Assert.IsTrue(2 == result[0].Count); }
public void Test1() { bool ret = OrmUtils.Model("User").TryCreateTable(true); Assert.IsTrue(ret); dynamic newuser = ModelObject.New("User"); newuser.Name = "wangxm"; newuser.Age = 18; bool ret2 = OrmUtils.Model("User").SetValues(newuser).Save(); Assert.IsTrue(ret2); dynamic newuser2 = ModelObject.New("User"); newuser2.Name = "hxy"; newuser2.Age = 14; bool ret3 = OrmUtils.Model("User").SetValues(newuser2).Save(); Assert.IsTrue(ret3); dynamic newuser3 = ModelObject.New("User"); newuser3.Name = "zhangsan"; newuser3.Age = 18; bool ret4 = OrmUtils.Model("User").SetValues(newuser3).Save(); Assert.IsTrue(ret4); dynamic newuser4 = ModelObject.New("User"); newuser4.Name = "lisi"; newuser4.Age = 10; bool ret5 = OrmUtils.Model("User").SetValues(newuser4).Save(); Assert.IsTrue(ret5); }