예제 #1
0
        public T FindById(int id)
        {
            T modelItem;

            using (var contex = new Database())
            {
                var item = contex.Set <K>().Find(id);
                modelItem = ConvertToModel(item);
            }

            return(modelItem);
        }
예제 #2
0
        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>());
        }