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;
    }
  • 相关阅读:
    WebBrowser
    hibernate关系映射(多对多)
    hibernate关系映射(多对一)
    使用maven构建hibernate
    使用maven构建web项目
    Chapter 6 ViewController
    Chapter 5 带颜色的同心圆
    Symbol(s) not found for architecture arm64
    反射实现NSCodingProtocol 帮助类
    UITableView默认选中第一行
  • 原文地址:https://www.cnblogs.com/wenming205/p/1284073.html
Copyright © 2011-2022 走看看