public object MapRow(System.Data.IDataReader reader, int rowNum) { User model = new User(); model.id = reader.GetInt32(0); model.name = reader.GetString(1); model.pwd = reader.GetString(2); return model; }
protected void login() { user = new User(); user.ID = 1; user.Name = "小明"; user.Gender = "男"; // Session["uid="] = 1; Session["uname="] = "小明"; // WriteCookie("uid", "1"); WriteCookie("uname", "小明"); }
public void test() { User t1 = new User(); t1.id = 123; t1.name = "zhuzhen"; t1.pwd = "321"; dao.save(t1); User t2 = new User(); t2.id = 321; t2.name = "guolili"; t2.pwd = "123"; dao.save(t2); foreach (User model in dao.getAll()) { string name = model.name; } }
//[Transaction(Spring.Transaction.TransactionPropagation.Required, ReadOnly = false)] //[Transaction] public void save(User model) { //setHibernateTemplate(); //sf.GetCurrentSession().Save(person); //ht.Save(person); //ISession s = sf.OpenSession(); //ITransaction t = s.BeginTransaction(); //s.FlushMode = FlushMode.Auto; //s.Save(person); //t.Commit(); //HibernateTemplate.TemplateFlushMode = TemplateFlushMode.Auto; HibernateTemplate.Save(model); //ISession s = HibernateTemplate.SessionFactory.OpenSession(); //ITransaction t = s.BeginTransaction(); //s.Save(model); //t.Commit(); //s.Close(); }
public ActionResult Index() { User user = new User(); user.name = "zhuzhen"; user.pwd = "123"; userService.save(user); IList<User> userList = userService.getAll(); System.Console.WriteLine(userList.Count); user = userService.getById(user.id); System.Console.WriteLine(user.name); user.pwd = "123456"; userService.update(user); userService.delete(user); ViewBag.Message = messageSource.GetMessage("name", CultureInfo.CurrentUICulture); return View(); }
//private HibernateTemplate ht; //public ISessionFactory sf { set; get; } //private void setHibernateTemplate() //{ // if (null == ht) // { // ht = new HibernateTemplate(this.sf); // ht.TemplateFlushMode = TemplateFlushMode.Auto; // ht.CacheQueries = true; // } //} public void delete(User model) { //sf.GetCurrentSession().Delete(tb_user); HibernateTemplate.Delete(model); }
public void update(User model) { dao.update(model); }
public void save(User model) { dao.save(model); }
public void delete(User model) { dao.delete(model); }
/// <summary> /// 用于向 User EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToUser(User user) { base.AddObject("User", user); }
partial void InsertUser(User instance);
private void detach_Users(User entity) { this.SendPropertyChanging(); entity.Account = null; }
private void attach_Users(User entity) { this.SendPropertyChanging(); entity.Account = this; }
public void update(User model) { userDao.update(model); }
public void save(User model) { userDao.save(model); }
public void delete(User model) { userDao.delete(model); }
public void update(User model) { //setHibernateTemplate(); //HibernateTemplate.Update(person); HibernateTemplate.Update(model); }
partial void UpdateUser(User instance);
/// <summary> /// 创建新的 User 对象。 /// </summary> /// <param name="id">ID 属性的初始值。</param> public static User CreateUser(global::System.Int64 id) { User user = new User(); user.ID = id; return user; }
partial void DeleteUser(User instance);