zoukankan      html  css  js  c++  java
  • NHibernate调用存储过程

      NHibernate与存储过程相联,实际上也就是与sqlclient,oledb,等SqlCommand,sqldataadapter,等相联.其主要步骤如下:

    public DataSet GetDs()

    {

                NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();

                ISessionFactoryImplementor factory = (ISessionFactoryImplementor)cfg.BuildSessionFactory();//这行重要
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText ="Company_GetPagedBrandList";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add("@startIndex", SqlDbType.Int);
                cmd.Parameters["@startIndex"].Value = startIndex;
                cmd.Parameters.Add("@endIndex", SqlDbType.Int);
                cmd.Parameters["@endIndex"].Value = endIndex;
                cmd.Parameters.Add("@brandId", SqlDbType.VarChar,10);
                cmd.Parameters["@brandId"].Value = brandId;
                SqlConnection conn = (SqlConnection)factory.OpenConnection();
                cmd.Connection = conn;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                return ds;
    }
  • 相关阅读:
    SQLServer多表连接查询
    SQLServer基本查询
    SQLServer索引
    SQLServer之数据类型
    设计模式小结
    SQL跨项目查询语法
    利用CountDownLatch和Semaphore测试案例
    JUC包下Semaphore学习笔记
    JUC包下CountDownLatch学习笔记
    JUC包下CyclicBarrier学习笔记
  • 原文地址:https://www.cnblogs.com/wenming205/p/1284073.html
Copyright © 2011-2022 走看看