Esempio n. 1
0
        public ActionResult Index()
        {
            using (var db = new JKLineEntities())
            {
                Member member = new Member() { id = "fff" + db.Members.Count(), password = "******", name = "new" + db.Members.Count() };
                db.Members.Add(member);
                try
                {
                    db.SaveChanges();

                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }

            }

            return View();
        }
        // GET api/member
        public ActionResult getArray(String name)
        {
            using (var db = new JKLineEntities())
            {

                var members = db.Members.ToArray();
                var newArray = Array.ConvertAll(members, item => new { name = item.name });
                return Json(newArray, JsonRequestBehavior.AllowGet);
                //return newArray;
            }
            //return new string[] { "value1", "value2" };
        }
        // GET api/values
        public IEnumerable<string> Get()
        {
            String s = "ff";
            using (var db = new JKLineEntities())
            {
                foreach(Member member in db.Members)
                {
                    s += member.name;
                }
            }

            return new string[] { "value1", "value2", s };
        }
Esempio n. 4
0
 private void DisposeJKLineEntities()
 {
     jklineEntities.Dispose();
     jklineEntities = null;
 }
Esempio n. 5
0
        public JKLineEntities GetJKLineEntites()
        {
            if (jklineEntities == null)
            {

                jklineEntities = new JKLineEntities();
            }
            return jklineEntities;
        }