1234567891011121314151617181920212223242526272829303132333435363738 |
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using AutoMapper;
- using Datory;
- using GxPress.Common.AppOptions;
- using GxPress.Common.Tools;
- using GxPress.Repository.Interface.Media;
- using Microsoft.Extensions.Options;
- namespace GxPress.Repository.Implement.Media
- {
- public class MediaLableRepository : IMediaLableRepository
- {
- private readonly Repository<Entity.tede2.Media.MediaLable> _repository;
- private readonly IMapper _mapper;
- private readonly string _connectionString;
- private readonly string _databaseTypestr;
- public MediaLableRepository(IOptionsMonitor<DatabaseOptions> dbOptionsAccessor, IMapper mapper)
- {
- _databaseTypestr = dbOptionsAccessor.CurrentValue.DatabaseType;
- _connectionString = dbOptionsAccessor.CurrentValue.ConnectionString;
- var databaseType =
- StringUtils.ToEnum<DatabaseType>(dbOptionsAccessor.CurrentValue.DatabaseType, DatabaseType.MySql);
- var database = new Database(databaseType, dbOptionsAccessor.CurrentValue.ConnectionString);
- _repository = new Repository<Entity.tede2.Media.MediaLable>(database);
- _mapper = mapper;
- }
- public IDatabase Database => _repository.Database;
- public string TableName => _repository.TableName;
- public List<TableColumn> TableColumns => _repository.TableColumns;
- public async Task<IEnumerable<int>> GetMediaIdsAysnc(int lableId)
- {
- return await _repository.GetAllAsync<int>(Q.Select(nameof(Entity.tede2.Media.MediaLable.MediaId)).Where(nameof(Entity.tede2.Media.MediaLable.LableId), lableId));
- }
- }
- }
|