You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.5 KiB

2 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using OrmTest.Demo;
  6. using OrmTest.Models;
  7. namespace OrmTest.UnitTest
  8. {
  9. public class EnumTest : UnitTestBase
  10. {
  11. private EnumTest() { }
  12. public EnumTest(int eachCount)
  13. {
  14. this.Count = eachCount;
  15. }
  16. public void Init()
  17. {
  18. var db = GetInstance();
  19. var shoolValue = SchoolEnum.HarvardUniversity;
  20. var enums = new SchoolEnum[] { shoolValue, SchoolEnum.UniversityOfOxford };
  21. var list = db.Queryable<StudentEnum>().AS("student").Where(it => it.SchoolId == shoolValue).Select(it=>it.SchoolId).ToList();
  22. var x = new StudentEnum()
  23. {
  24. Name = shoolValue.ToString(),
  25. SchoolId = shoolValue
  26. };
  27. var x2 = db.Queryable<StudentEnum>().AS("student").Where(it => enums.Contains(it.SchoolId)).ToSql();
  28. var id= db.Insertable(x).AS("student").ExecuteReturnIdentity();
  29. var data = db.Queryable<StudentEnum>().AS("student").InSingle(id);
  30. shoolValue = SchoolEnum.UniversityOfOxford;
  31. var sql= db.Updateable<StudentEnum>().AS("student").UpdateColumns(it=>new StudentEnum() { Name="a" , SchoolId= shoolValue }).Where(it=>it.Id==id).ToSql();
  32. var sql2 = db.Updateable<StudentEnum>().AS("student").UpdateColumns(it => new StudentEnum() { Name = "a", SchoolId = SchoolEnum.UniversityOfOxford }).Where(it => it.Id == id).ToSql();
  33. }
  34. }
  35. }