12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using SnapshotWinFormsApp.Application.Dtos;
- using SnapshotWinFormsApp.Repository.Interfaces;
- using SqlSugar;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SnapshotWinFormsApp.Repository;
- public class SelectRepository<T> : ISelectRepository<T>
- where T : DataTransmission.Entity.Entity, new()
- {
- private readonly SqlSugarClient _db;
- public SelectRepository(CreateInstanceInDto inDto)
- {
- var context = inDto.DbSqlServer;
- _db = context.DbItems.GetValueOrDefault(inDto.Key + "PGSQLDB");
- }
- public IList<T> GetAll()
- {
- return _db.Queryable<T>().ToList();
- }
- public async Task<List<T>> GetAllAsync(CancellationToken token)
- {
- return await _db.Queryable<T>().ToListAsync(token);
- }
- public T GetById(string id)
- {
- return _db.Queryable<T>().Where(m => m.Id == id).First();
- }
- public ISugarQueryable<T> Queryable()
- {
- return _db.Queryable<T>();
- }
- }
|