public static IList<Mail> GetAllReals()
        {
            IList<Mail> list;
            ISession session = NHelper.GetCurrentSession();
            IQuery iq = session.CreateQuery("from M where Type = :type").SetString("type", "li");
            list = iq.List<Mail>();
            session.Close();
            return list;
        }新手,看不懂上面的代码。
ISession ,IQuery 是什么?CreateQuery在哪定义的?怎么连接的数据库?
list 又是什么?下面是GetCurrentSession的定义
 public static ISession GetCurrentSession()
        {
            HttpContext context = HttpContext.Current; //system.web 命名空间下
            ISession currentSession = context.Items[CurrentSessionKey] as ISession; // Items 是键值对            if (currentSession == null || !(currentSession.IsOpen)) // 先行如此。
            {
                currentSession = sessionFactory.OpenSession();
                context.Items[CurrentSessionKey] = currentSession;
            }
            return currentSession;
        }

解决方案 »

  1.   

    ISession ,IQuery  这些东西 人家都已经写好了得 你那应该有引用的 ·  那边应该有
      

  2.   

    ISession ,IQuery是接口,从语法上面就看出来嘛,接口一般以大些的“I”字母开头,以“able”结尾。用鼠标在“CreateQuery”上,点右键,选择“转到定义”就可以看到了。。list是泛型集合,类似于数组,只不过这个更加方便比一般的集合效率更好
      

  3.   

    好象是用了NHIBERNATE的东西.
    要不就是其他ORM.
      

  4.   

    有个hibernate.cfg.xml文件
    里面内容:
    <?xml version="1.0" encoding="utf-8"?>
    <!-- 
    This template was written to work with NHibernate.Test.
    Copy the template to your NHibernate.Test project folder and rename it in hibernate.cfg.xml and change it 
    for your own use before compile tests in VisualStudio.
    -->
    <hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
      <session-factory>
        <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
        <property name="connection.connection_string">
          Server=(local);uid=aw;pwd=aw;database=aw;
        </property>
        <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
        <property name="show_sql">true</property>
        <mapping assembly="NHModel"/>
      </session-factory>
    </hibernate-configuration>Nhibernate是什么?其他人留下的程序,这种程序从哪入手?应该学习什么?指个方向?
      

  5.   

    Nhibernate 是ORM框架。
    你去博客园找找李永京和刘冬的文章。。
      

  6.   

    用Nhibernate的项目多不多?值不值得去学习?
      

  7.   

    现在有个问题,数据库连接改了但还是读的老数据库的数据,不是只有这一个hibernate.cfg.xml配置文件?
      

  8.   

    ISession ,IQuery  是接口
    NHelper.GetCurrentSession(); 是获取ISession接口的实例
    session.CreateQuery()应该是获取对象的方法
    我看过类似的代码。基本都把像CreateQuery()的实现封装成一个类  生成dll 加引用的 ,你看方法只能看到一个接口。真正的源码在dll里了。