コード例 #1
0
        // GET api/<controller>/5
        public Product Get(int id)
        {
            //connect
            using (VirtuosoModels db = new VirtuosoModels())
            {
                db.Configuration.ProxyCreationEnabled = false;

                Product objP = (from p in db.Products
                               where p.ProductID == id
                               select p).FirstOrDefault();

                return objP;

            }

            //return "value";
        }
コード例 #2
0
        // GET api/<controller>
        public IEnumerable<Product> Get()
        {
            //connect
            using (VirtuosoModels db = new VirtuosoModels())
            {
                //make sure json parsing works with the ef object
                db.Configuration.ProxyCreationEnabled = false;

                //query
                var objP = from p in db.Products
                           orderby p.ProductID
                           select p;

                return objP.ToList();
            }

            //return new string[] { "value1", "value2" };
        }