首页 新闻 会员 周边 捐助

object references an unsaved transient instance before flushing

0
悬赏园豆:50 [待解决问题]

public class Role
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }

public virtual int Level { get; set; }

public virtual bool Isman { get; set; }

public virtual User User { get; set; }

 }

}

public class User
{
public virtual int Id { get; set; }

public virtual string Username { get; set; }

public virtual string Password { get; set; }

public virtual int Age { get; set; }

public virtual string Email { get; set; }

}
}

 

子表是role,父表是user

 

 roletemp.User = peer.LoginUser;

public void SaveRole(Role role) {
using (var session = NhibernateHelper.OpenSession())
{
using (var transaction = session.BeginTransaction())
{

session.Save(role);
transaction.Commit();

}

}

}

执行出错 object references an unsaved transient instance before flushing

要怎么改能保存role?

小明被拐走了的主页 小明被拐走了 | 初学一级 | 园豆:152
提问于:2015-11-28 18:11
< >
分享
所有回答(1)
0

save-update

jello chen | 园豆:7336 (大侠五级) | 2015-11-28 19:59
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册