using IMCS.CCS.Entitys; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace IMCS.CCS.Repository { public class DictionaryRepository : IDictionaryRepository { private readonly CcsContext _context; public DictionaryRepository(CcsContext context) { _context = context; } //查询列表 public async Task> GetList(Dictionary vo) { IQueryable list = _context.Dictionary; if (!string.IsNullOrEmpty(vo.Type)) { list = list.Where(x => x.Type == vo.Type); } return await list.ToListAsync(); } //查询详情 public async Task GetById(int id) { Dictionary device = await _context.Dictionary.FindAsync(id); return device; } //添加详情 public async Task Create(Dictionary vo) { _context.Dictionary.Add(vo); await _context.SaveChangesAsync(); return true; } //更新详情 public async Task Update(Dictionary vo) { _context.Entry(vo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return true; } } }