hmf_09 2015-03-20 02:44 采纳率: 0%
浏览 1860

NHibernate 保存实体类时无法转换类型

求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]”

    估计是上面实体类的属性与保存时映射的类型不搭配。但都是工具生成的,不知道要怎么改。求解!!
  • 写回答

1条回答 默认 最新

  • hmf_09 2015-03-20 04:01
    关注

    实体类生成的问题!使用codesmith的nhibernate模版的格式有问题,或者是不匹配新版本的NHbernate 4. 结束。

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料