求NHibernate会的请教!
实体类:Userinfo 和 Userinfo.hbm.xml是用codesmith生成的。userinfo属性如下:
protected Guid _id;
protected string _userName;
protected string _password;
protected string _email;
protected int _state = 0 ;
protected string _passwordQuestion;
protected string _passwordAnswer;
protected string _nick;
protected string _realName;
protected string _images;
protected string _backgroundImage;
protected bool _sex;
protected string _mobilePhone;
protected string _address;
protected DateTime _birthday;
protected string _loastLoginIP;
protected DateTime _regTime;
protected int _isDel;
protected DateTime _beginTime = DateTime.Now ;
protected DateTime _updateTime;
protected UserRole _userRole;
protected IList _newsCommentsReplies;
protected IList _publishNewses;
protected IList _newsCommentses;
protected IList _userFavorClasses;
我写个userdao 保存实体类 userinfo,代码如下:
ICriteria criteria = _session.CreateCriteria(typeof(UserRole));
userInfo.UserRole = (UserRole)criteria.List<UserRole>()[0];
_session.Save(userInfo);
_session.Flush();
Save的时候抛出异常:
无法将类型为“System.Collections.ArrayList”的对象强制转换为类型“Syste m.Collections.Generic.IEnumerable`1[System.Object]”
估计是上面实体类的属性与保存时映射的类型不搭配。但都是工具生成的,不知道要怎么改。求解!!