1234567891011121314151617181920212223242526272829303132333435 |
- using SnapshotWinFormsApp.Repository.Interfaces;
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SnapshotWinFormsApp.Repository;
- public class Repository<T> : IRepository<T> where T : class, new()
- {
- private readonly SqlSugarClient _db;
- public Repository(DbSqlServer context, string key)
- {
- _db = context.DbItems.GetValueOrDefault(key+ "SQLServerDB");
- }
- public T GetById(int id)
- {
- return _db.Queryable<T>().InSingle(id);
- }
- public List<T> GetAll()
- {
- return _db.Queryable<T>().ToList();
- }
- public ISugarQueryable<T> Queryable()
- {
- return _db.Queryable<T>();
- }
- }
|