public T FindById(int id) { T modelItem; using (var contex = new Database()) { var item = contex.Set <K>().Find(id); modelItem = ConvertToModel(item); } return(modelItem); }
public virtual IEnumerable <T> GetAll() { IEnumerable <T> list; using (var context = new Database()) { list = context .Set <K>() .AsNoTracking() .ToList() .Select(x => ConvertToModel(x)) .ToList(); } return(list ?? new List <T>()); }