MediaLableRepository.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. using System.Collections.Generic;
  2. using AutoMapper;
  3. using Datory;
  4. using GxPress.Common.AppOptions;
  5. using GxPress.Common.Tools;
  6. using GxPress.Repository.Interface.Media;
  7. using Microsoft.Extensions.Options;
  8. namespace GxPress.Repository.Implement.Media
  9. {
  10. public class MediaLableRepository : IMediaLableRepository
  11. {
  12. private readonly Repository<Entity.tede2.Media.MediaLable> _repository;
  13. private readonly IMapper _mapper;
  14. private readonly string _connectionString;
  15. private readonly string _databaseTypestr;
  16. public MediaLableRepository(IOptionsMonitor<DatabaseOptions> dbOptionsAccessor, IMapper mapper)
  17. {
  18. _databaseTypestr = dbOptionsAccessor.CurrentValue.DatabaseType;
  19. _connectionString = dbOptionsAccessor.CurrentValue.ConnectionString;
  20. var databaseType =
  21. StringUtils.ToEnum<DatabaseType>(dbOptionsAccessor.CurrentValue.DatabaseType, DatabaseType.MySql);
  22. var database = new Database(databaseType, dbOptionsAccessor.CurrentValue.ConnectionString);
  23. _repository = new Repository<Entity.tede2.Media.MediaLable>(database);
  24. _mapper = mapper;
  25. }
  26. public IDatabase Database => _repository.Database;
  27. public string TableName => _repository.TableName;
  28. public List<TableColumn> TableColumns => _repository.TableColumns;
  29. }
  30. }