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.

39 lines
1.0 KiB

2 years ago
  1. using SqlSugar;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. namespace OrmTest.UnitTest
  7. {
  8. public class DataTest2 : UnitTestBase
  9. {
  10. public interface IEntity<T> {
  11. T ID { get; set; }
  12. }
  13. public abstract class Entity<T> : IEntity<T>
  14. {
  15. public virtual T ID { get; set; }
  16. }
  17. public class MyModel: Entity<int>
  18. {
  19. public override int ID { get; set; }
  20. }
  21. private DataTest2() { }
  22. public DataTest2(int eachCount)
  23. {
  24. this.Count = eachCount;
  25. }
  26. public void Init()
  27. {
  28. var db = GetInstance();
  29. var t1 = db.Queryable<MyModel>().AS("Student").ToList();
  30. }
  31. public SqlSugarClient GetInstance()
  32. {
  33. SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
  34. return db;
  35. }
  36. }
  37. }