コード例 #1
0
        public IList<Models.Person> Get()
        {
            using (var context = new EFContext())
            {
                var query = from x in context.People
                            select x;

                var list = query.ToList<SQLServerRepositories.Database.Person>();

                var people = _mapper.Map<List<Models.Person>>(list);

                return people;

            }
        }
コード例 #2
0
        public Models.Person GetById(int id)
        {
            using (var context = new EFContext())
            {
                var query = from x in context.People
                            where x.ID == id
                            select x;

                if (query.Count() == 1)
                {
                    var result = query.SingleOrDefault();
                    var person = _mapper.Map<Models.Person>(result);
                    return person;
                }

                return new Models.Person();

            }
        }