데이터베이스에 새 사용자를 저장하려고하면 문제가 있습니다. 내 코드 :SaveOrUpdate()에서 Collection을 null로 설정할 수 없습니다.
if (!user.ValidateUser(username, password))
{
using (var session = NHibernateHelper.OpenSession())
{
User u = new User();
u.Name = username;
u.Email = string.Empty;
u.Password = "123456";
using (var transact = session.Transaction)
{
session.SaveOrUpdate(u); // I have an exception in this line
transact.Commit();
}
}
}
오류 :
어떻게 데이터베이스에 새 사용자를 저장하려면?Collection cannot be null. Parameter name: c
P. session.Save(user1);
나에게도이 예외를주지 마라.
업데이트 : 사용자 클래스
public partial class User
{
public User()
{
this.CurrentTestings = new HashSet<CurrentTesting>();
this.ResultsSet = new HashSet<ResultTesting>();
}
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual string Password { get; set; }
public virtual string Email { get; set; }
public virtual ICollection<CurrentTesting> CurrentTestings { get; set; }
public virtual ICollection<ResultTesting> ResultsSet { get; set; }
}
'User' 클래스를 게시 해주십시오. –
@Rory McCrossan 업데이트 – LuckSound
재사용 대신 새로운 사용자를 어떻게 만듭니 까? – abatishchev