Example #1
0
        // GET api/values
        public IEnumerable <Models.Product> Get()
        {
            List <Models.Product> result = new List <Models.Product>();

            Models.DB_testEntities db = new Models.DB_testEntities();
            result = (from s in db.Products select s).ToList();

            return(result);
        }
Example #2
0
        // GET api/values/5
        public IEnumerable <ProductWithImage> Get(int id)
        {
            List <ProductWithImage> result = new List <ProductWithImage>();

            Models.DB_testEntities db = new Models.DB_testEntities();

            result = (from p in db.Products
                      join b in db.Images on p.DefaultImageId equals b.id
                      select new ProductWithImage {
                Name = p.Name, Price = p.Price, Path = b.path
            }).ToList();

            return(result);
        }