标题:Nhibernate配置出了问题
取消只看楼主
lovehuxiaohu
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-3-31
结帖率:0
已结贴  问题点数:20 回复次数:1 
Nhibernate配置出了问题
执行程序时,提示以下错误:
{NHibernate.MappingException: Could not compile the mapping document: Entity.UserInfo.hbm.xml ---> System.Collections.Generic.KeyNotFoundException: 给定关键字不在字典中。  。。
好像是映射文件不能找到:Could not compile the mapping document: Entity.UserInfo.hbm.xml

ISessionFactory _sessionFactory;

            NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
            cfg.AddAssembly("Entity");

            _sessionFactory = cfg.BuildSessionFactory();

            using (NHibernate.ISession session = _sessionFactory.OpenSession())
            {
 
                try
                {
                    IQuery query = session.CreateQuery("select * from UserInfo ");
                    IList<UserInfo> list = query.List<UserInfo>();
                    if (list.Count > 0)
                    {
                        return list[0];
                    }

                    else
                        return null;
                }
                catch (System.Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    session.Close();
                }
            }
这段代码出现错误。。 各位大侠帮忙解决一些喽。。 O(∩_∩)O谢谢~\(≧▽≦)/~啦啦啦!!
搜索更多相关主题的帖子: Nhibernate 
2010-03-31 16:06
lovehuxiaohu
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-3-31
得分:0 
映射文件都已经跟对应表的字段一一对应好了。对NHibernate.dll组件的添加、类库的引用都完成了。 问题就是解决不了!
2010-04-01 15:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-301182-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.539622 second(s), 10 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved