新しいユーザーをデータベースに保存しようとすると、問題が発生します。私のコード:
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();
}
}
}
エラー:
コレクションを null にすることはできません。パラメータ名:c
新しいユーザーをデータベースに保存するには?
PSsession.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; }
}