Пример #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();
        }
Пример #2
0
        // 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" };
        }
Пример #3
0
        // 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 };
        }
Пример #4
0
 private void DisposeJKLineEntities()
 {
     jklineEntities.Dispose();
     jklineEntities = null;
 }
Пример #5
0
        public JKLineEntities GetJKLineEntites()
        {
            if (jklineEntities == null)
            {

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