DbContextServiceProvider.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Ant.Core.Visitors;
  2. using Ant.Data;
  3. using Ant.Infrastructure;
  4. using Ant.Query;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Data.SqlClient;
  9. using System.Linq;
  10. using System.Text;
  11. namespace Ant.SqlServer
  12. {
  13. class DbContextServiceProvider : IDbContextServiceProvider
  14. {
  15. PagingMode _pagingMode;
  16. public DbContextServiceProvider(PagingMode pagingMode)
  17. {
  18. this._pagingMode = pagingMode;
  19. }
  20. /// <summary>
  21. /// 创建是SQL2012之前的数据库带分页的
  22. /// </summary>
  23. /// <returns></returns>
  24. public IDbExpressionTranslator CreateDbExpressionTranslator()
  25. {
  26. if (_pagingMode == Ant.Data.PagingMode.ROW_NUMBER)
  27. {
  28. return DbExpressionTranslator.Instance;
  29. }
  30. else if (_pagingMode == Ant.Data.PagingMode.OFFSET_FETCH)
  31. {
  32. return DbExpressionTranslator_OffsetFetch.Instance;
  33. }
  34. throw new NotSupportedException();
  35. }
  36. }
  37. }