csharp:Nhibernate Procedure with CreateSQLQuery and GetNamedQuery

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="Domain" namespace="Domain" xmlns="urn:nhibernate-mapping-2.2"><class name="DuCardType" table="DuCardType" lazy="true" ><id name="CardTypeId" column="CardTypeId"><generator class="identity" /></id><property name="CardTypeName"><column name="CardTypeName" sql-type="nvarchar" not-null="true" /></property><property name="CardTypeColor"><column name="CardTypeColor" sql-type="nvarchar" not-null="true" /></property><sql-insert name="InsertDuCardType">exec proc_Insert_DuCardType ?,?,?</sql-insert><!--<sql-insert name="SqlInsertDuCardType">INSERT INTO DuCardType (CardTypeName, CardTypeColor) VALUES (?,?,?)</sql-insert>--><!--<sql-insert><sql-update><sql-delete>--></class>
</hibernate-mapping>

  

 

  ///<summary>/// 追加记录返回值///</summary>///<param name="DuCardType">输入参数:DuCardTypeInfo</param>///<param name="CardTypeId">返回参数:CardTypeId</param>///<returns>返回是否添加的个数</returns>public int InsertDuCardTypeOutput(DuCardType cardType, out int cardTypeId){int sid = 1;NHibernate.ISession session = this.SessionFactory.GetCurrentSession();ITransaction tran = session.BeginTransaction();try{session.Save(cardType);cardTypeId = cardType.CardTypeId;tran.Commit();}catch (MappingException ex){sid = 0;tran.Rollback();throw ex;}return sid;//return dal.InsertDuCardTypeOutput(duCardType,out cardTypeId);}

 

  ///<summary>///修改记录///</summary>///<param name="DuCardType">输入参数:DuCardTypeInfo</param>///<returns>返回修改的多少记录数</returns>public int UpdateDuCardType(DuCardType duCardType){int sid = 1;NHibernate.ISession session = this.SessionFactory.GetCurrentSession();ITransaction tran = session.BeginTransaction();try{session.Update(duCardType);tran.Commit();}catch (Exception ex){sid = 0;tran.Rollback();throw ex;}return sid;//return dal.UpdateDuCardType(duCardType);}

  

 /// <summary>/// 删除/// </summary>/// <param name="customer"></param>/// <returns></returns>public int Dell(DuCardType cardType){int sid = 1;NHibernate.ISession session = this.SessionFactory.GetCurrentSession();ITransaction tran = session.BeginTransaction();try{session.Delete(cardType);tran.Commit();}catch (Exception ex){sid = 0;tran.Rollback();throw ex;}return sid;}

  

 

 ///<summary>/// 删除记录///</summary>///<param name="cardTypeId">输入参数:CardTypeId</param>///<returns>返回删除记录条数</returns>public bool DeleteDuCardType(int cardTypeId){bool isok = false;try{IDbDataParameter[] par = new SqlParameter[]{                   new SqlParameter(),};par[0].ParameterName = "CardTypeId";par[0].Value = cardTypeId;isok = DBHelper.ExecuteNonQuery(SessionFactory, CommandType.StoredProcedure, "proc_Delete_DuCardType");}catch (NotImplementedException ex){ex.Message.ToString();}return isok;//return dal.DeleteDuCardType(cardTypeId);}/// <summary>/// 删除/// </summary>/// <param name="customer"></param>/// <returns></returns>public int Dell(DuCardType cardType){int sid = 1;NHibernate.ISession session = this.SessionFactory.GetCurrentSession();ITransaction tran = session.BeginTransaction();try{session.Delete(cardType);tran.Commit();}catch (Exception ex){sid = 0;tran.Rollback();throw ex;}return sid;}///<summary>/// 删除多条记录///</summary>///<param name="cardTypeId">输入参数:CardTypeId</param>///<returns>返回删除多少记录</returns>public bool DeleteDuCardTypeId(string cardTypeId){bool isok = false;           try{IDbDataParameter[] par = new SqlParameter[]{                   new SqlParameter(),};par[0].ParameterName = "CardTypeId";par[0].Value = cardTypeId;isok = DBHelper.ExecuteNonQuery(SessionFactory, CommandType.StoredProcedure, "proc_Delete_DuCardTypeId");}catch (NotImplementedException ex){ex.Message.ToString();}return isok;//return dal.DeleteDuCardTypeId(cardTypeId);}

  

 /// <summary>/// /// </summary>/// <param name="id"></param>/// <returns></returns>public IList<DuCardType> CardTypeSql(int id){NHibernate.ISession session = this.SessionFactory.GetCurrentSession();IList<DuCardType> card = new List<DuCardType>();if (!object.Equals(session, null)){//写法1//return _session.CreateQuery("from DuCardType c where c.CardTypeName='" + firstname + "'")//    .List<DuCardType>();//写法2:位置型参数//return _session.CreateQuery("from DuCardType c where c.CardTypeName=?")//    .SetString(0, firstname)//    .List<DuCardType>();//写法4.//var sql = "select * from DuCardType";//var query = session.CreateSQLQuery(sql)//.AddScalar("CardTypeId", NHibernateUtil.Int32)//.AddScalar("CardTypeName", NHibernateUtil.String)//.AddScalar("CardTypeColor", NHibernateUtil.String)//.SetResultTransformer(Transformers.AliasToBean<DuCardType>());//result = query.List<DuCardType>();  //写法3:命名型参数(推荐)var query = session.CreateSQLQuery("Select * FROM DuCardType where CardTypeId=:CardTypeId").SetInt32("CardTypeId", id).SetResultTransformer(Transformers.AliasToBean(typeof(DuCardType)));card = query.List<DuCardType>();}return card;}/// <summary>/// 存储过程/// </summary>/// <param name="id"></param>/// <returns></returns>public IList<DuCardType> CardTypeProcedures(int id){//读到数据IList<DuCardType> li = null;NHibernate.ISession session = this.SessionFactory.GetCurrentSession();string sql = @"exec proc_Select_DuCardType :CardTypeId";IQuery query = session.CreateSQLQuery(sql).SetInt32("CardTypeId", id);var list = query.List();foreach (object[] item in list){li =new List<DuCardType>();var cardType = new DuCardType();cardType.CardTypeId = (int)item[0];cardType.CardTypeName = (string)item[1];cardType.CardTypeColor = item[2].ToString();li.Add(cardType);}//query = query.SetResultTransformer(Transformers.AliasToBean<OrderDto>());//var list2 = query.List<OrderDto>();var result = from cardType in liorderby cardType.CardTypeName //名字排序select cardType;return li;}

  GetNamedQuery: 存储过程

  /// <summary>/// 存储过程查询/// </summary>/// <param name="id"></param>/// <returns></returns>public IList<DuCardType> CardTypeProcedures(int id){//读到数据IList<DuCardType> li = null;NHibernate.ISession session = this.SessionFactory.GetCurrentSession();try{IQuery query = session.GetNamedQuery("proc_Select_DuCardType").SetParameter("CardTypeId", id).SetResultTransformer(Transformers.AliasToBean(typeof(DuCardType)));li = query.List<DuCardType>();//var executor = new HibernateStoredProcedureExecutor(session);//var lie = executor.ExecuteStoredProcedure<DuCardType>(//  "proc_Select_DuCardType",  //find no//  new[]//  {//      new SqlParameter("CardTypeId", id),//      //new SqlParameter("startDate", startDate),//     // new SqlParameter("endDate", endDate),//  });//li = lie.ToList();//return li;//string sql = @"exec proc_Select_DuCardType :CardTypeId";//IQuery query = session.CreateSQLQuery(sql)//    .SetInt32("CardTypeId", id);//var list = query.List();//foreach (object[] item in list)//{//    li = new List<DuCardType>();//    var cardType = new DuCardType();//    cardType.CardTypeId = (int)item[0];//    cardType.CardTypeName = (string)item[1];//    cardType.CardTypeColor = item[2].ToString();//    li.Add(cardType);//}query = query.SetResultTransformer(Transformers.AliasToBean<OrderDto>());var list2 = query.List<OrderDto>();//var result = from cardType in li//             orderby cardType.CardTypeName //名字排序//             select cardType;}catch (MappingException ex){ex.Message.ToString();}return li;}

  

 /// <summary>/// Linq查询/// </summary>/// <param name="id"></param>/// <returns></returns>public IQueryable<DuCardType> getCardTypeID(int id){NHibernate.ISession session = this.SessionFactory.GetCurrentSession();var query = session.Query<DuCardType>();var result = from cardType in querywhere cardType.CardTypeId == idselect cardType;return result;}

  

 /// <summary>/// 存储过程分页/// 涂聚文 2016.07.03/// </summary>/// <param name="strwhere">Where条件</param>/// <param name="aecdesc">排序字段</param>/// <param name="pageIndex">开始页码</param>/// <param name="pageSize">页大小</param>/// <param name="RecordCount">输出总页数</param>/// <returns></returns>public DataTable GetDataPage(string strwhere, string aecdesc, int pageIndex, int pageSize, out int RecordCount){NHibernate.ISession session = this.SessionFactory.GetCurrentSession();DataSet data = new DataSet();try{//SessionFactory.ConnectionProvider.DriverIDbCommand cmd = SessionFactory.OpenSession().Connection.CreateCommand();//cmd.CommandText = "testaa";//IDbConnection con = session.Connection;//Type conType = con.GetType();//string conTypeName = conType.FullName;// if (!conTypeName.EndsWith("Connection"))//    throw new Exception("Unable to interpret connection type name: " + conTypeName);//string adapterTypeName = conTypeName.Substring(0, conTypeName.Length - 10) + "DataAdapter";IDbDataAdapter adapter = new SqlDataAdapter();//IDbDataAdapter adapter = conType.Assembly.CreateInstance(adapterTypeName) as IDbDataAdapter;//if (adapter == null)//    throw new Exception("Unable to load IDbDataAdapter: " + adapterTypeName);  // IDbCommand cmd = con.CreateCommand();cmd.CommandText = "GetPagedRecordFor2005_2008";cmd.CommandType = CommandType.StoredProcedure;IDbDataParameter p = cmd.CreateParameter();IDbDataParameter p1 = cmd.CreateParameter();IDbDataParameter p2 = cmd.CreateParameter();IDbDataParameter p3 = cmd.CreateParameter();IDbDataParameter p4 = cmd.CreateParameter();IDbDataParameter p5 = cmd.CreateParameter();IDbDataParameter p6 = cmd.CreateParameter();// IDbDataParameter p7 = cmd.CreateParameter();if (string.IsNullOrEmpty(strwhere)){strwhere = " 1=1 ";}p.ParameterName = "Table";p.Value = "DuCardType";p1.ParameterName = "TIndex";p1.Value = "CardTypeId";p2.ParameterName = "Column";p2.Value = " * "; p3.ParameterName = "Sql";p3.Value = strwhere;p4.ParameterName = "PageIndex";p4.Value = pageIndex;p5.ParameterName = "PageSize";p5.Value = pageSize;p6.ParameterName = "Sort";p6.Value = aecdesc;//p1.ParameterName = "geovindu";//p1.Size = 10;//p1.Direction = ParameterDirection.Output;//p7.ParameterName = "TotalRecords";//p7.Size = 10;//p7.Direction = ParameterDirection.Output;cmd.Parameters.Add(p);cmd.Parameters.Add(p1);cmd.Parameters.Add(p2);cmd.Parameters.Add(p3);cmd.Parameters.Add(p4);cmd.Parameters.Add(p5);cmd.Parameters.Add(p6);// cmd.Parameters.Add(p7);adapter.SelectCommand = cmd;adapter.Fill(data);//RecordCount =(int)p7.Value;         cmd.Cancel();cmd.Dispose();RecordCount = data.Tables[0].Rows.Count;}catch (NotImplementedException ex){RecordCount = 0;ex.Message.ToString();}return data.Tables[0];// return dal.GetDataPage(strwhere, aecdesc, pageIndex, pageSize, out RecordCount);}

 

 /// <summary>/// 存储过程分页/// 涂聚文 2016.07.03/// </summary>/// <param name="strwhere">Where条件</param>/// <param name="aecdesc">排序字段</param>/// <param name="pageIndex">开始页码</param>/// <param name="pageSize">页大小</param>/// <param name="RecordCount">输出总页数</param>/// <returns></returns>public DataTable GetDataPage(string strwhere, string aecdesc, int pageIndex, int pageSize, out int RecordCount){NHibernate.ISession session = this.SessionFactory.GetCurrentSession();DataSet data = new DataSet();try{//SessionFactory.ConnectionProvider.DriverIDbCommand cmd = SessionFactory.OpenSession().Connection.CreateCommand();//cmd.CommandText = "testaa";//IDbConnection con = session.Connection;//Type conType = con.GetType();//string conTypeName = conType.FullName;// if (!conTypeName.EndsWith("Connection"))//    throw new Exception("Unable to interpret connection type name: " + conTypeName);//string adapterTypeName = conTypeName.Substring(0, conTypeName.Length - 10) + "DataAdapter";IDbDataAdapter adapter = new SqlDataAdapter();//IDbDataAdapter adapter = conType.Assembly.CreateInstance(adapterTypeName) as IDbDataAdapter;//if (adapter == null)//    throw new Exception("Unable to load IDbDataAdapter: " + adapterTypeName);  // IDbCommand cmd = con.CreateCommand();//1.// cmd.CommandText = "GetPagedRecordFor2005_2008";// cmd.CommandType = CommandType.StoredProcedure;// IDbDataParameter p = new SqlParameter();// cmd.CreateParameter();// IDbDataParameter p1 = cmd.CreateParameter();// IDbDataParameter p2 = cmd.CreateParameter();// IDbDataParameter p3 = cmd.CreateParameter();// IDbDataParameter p4 = cmd.CreateParameter();// IDbDataParameter p5 = cmd.CreateParameter();// IDbDataParameter p6 = cmd.CreateParameter();IDbDataParameter p7 = cmd.CreateParameter();// if (string.IsNullOrEmpty(strwhere))// {//     strwhere = " 1=1 ";// }// p.ParameterName = "Table";// p.Value = "DuCardType";// p1.ParameterName = "TIndex";// p1.Value = "CardTypeId";// p2.ParameterName = "Column";// p2.Value = " * "; // p3.ParameterName = "Sql";// p3.Value = strwhere;// p4.ParameterName = "PageIndex";// p4.Value = pageIndex;// p5.ParameterName = "PageSize";// p5.Value = pageSize;// p6.ParameterName = "Sort";// p6.Value = aecdesc;// //p1.ParameterName = "geovindu";// //p1.Size = 10;// //p1.Direction = ParameterDirection.Output;//输出值// //p7.ParameterName = "TotalRecords";// //p7.Size = 10;// //p7.Direction = ParameterDirection.Output;// cmd.Parameters.Add(p);// cmd.Parameters.Add(p1);// cmd.Parameters.Add(p2);// cmd.Parameters.Add(p3);// cmd.Parameters.Add(p4);// cmd.Parameters.Add(p5);// cmd.Parameters.Add(p6);cmd.Parameters.Add(p7);// adapter.SelectCommand = cmd;// adapter.Fill(data);// //RecordCount =(int)p7.Value;         // cmd.Cancel();// cmd.Dispose();//2.      IDbDataParameter[] par = new SqlParameter[]{new SqlParameter(), //表名new SqlParameter(),//主键,可以带表头new SqlParameter(),//读取字段new SqlParameter(),//Where条件new SqlParameter(),//开始页码new SqlParameter(),//页大小new SqlParameter(),//排序字段};if (string.IsNullOrEmpty(strwhere)){strwhere = " 1=1 ";}par[0].ParameterName = "Table"; //表名par[0].Value="DuCardType";par[1].ParameterName = "TIndex";par[1].Value = "CardTypeId";par[2].ParameterName = "Column";par[2].Value = " * ";par[3].ParameterName = "Sql";//查询条件par[3].Value = strwhere;par[4].ParameterName = "PageIndex";par[4].Value = pageIndex;par[5].ParameterName = "PageSize";par[5].Value = pageSize;par[6].ParameterName = "Sort";par[6].Value = aecdesc;data = DBHelper.ExecuteDataSet(SessionFactory, CommandType.StoredProcedure, "GetPagedRecordFor2005_2008", par);RecordCount = data.Tables[0].Rows.Count;}catch (NotImplementedException ex){RecordCount = 0;ex.Message.ToString();}return data.Tables[0];// return dal.GetDataPage(strwhere, aecdesc, pageIndex, pageSize, out RecordCount);}

  

 

 

 /// <summary>/// 2016 geovindu/// </summary>public static class IListConverDataTable{/// <summary>/// /// </summary>/// <typeparam name="T"></typeparam>/// <param name="data"></param>/// <returns></returns>public static DataTable ToDataTable<T>(this IList<T> data){PropertyDescriptorCollection properties =TypeDescriptor.GetProperties(typeof(T));DataTable table = new DataTable();foreach (PropertyDescriptor prop in properties)table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);foreach (T item in data){DataRow row = table.NewRow();foreach (PropertyDescriptor prop in properties)row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;table.Rows.Add(row);}return table;}/// <summary>/// /// </summary>/// <param name="list"></param>/// <returns></returns>public static DataTable ToDataTable(IList list){DataTable result = new DataTable();if (list.Count > 0){PropertyInfo[] propertys = list[0].GetType().GetProperties();foreach (PropertyInfo pi in propertys){result.Columns.Add(pi.Name, pi.PropertyType);}for (int i = 0; i < list.Count; i++){ArrayList tempList = new ArrayList();foreach (PropertyInfo pi in propertys){object obj = pi.GetValue(list[i], null);tempList.Add(obj);}object[] array = tempList.ToArray();result.LoadDataRow(array, true);}}return result;}}

  

 DBHelper.cs

          //private IDbConnection _idbConnection;private IDataReader _iDataReader;private IDbCommand _idbCommand;private IDbTransaction _idbTransaction;private IDbDataParameter[] _idbParameters;/// <summary>/// /// </summary>public IDbConnection Connection{get { return _idbConnection; }set { _idbConnection = value; }}public IDataReader DataReader{get { return _iDataReader; }set { _iDataReader = value; }}public IDbCommand Command{get { return _idbCommand; }set { _idbCommand = value; }}public IDbTransaction Transaction{get { return _idbTransaction; }set { _idbTransaction = value; }}public IDbDataParameter[] Parameters{get { return _idbParameters; }set { _idbParameters = value; }}public static IDbTransaction GetTransaction(NHibernate.ISession session)  {  IDbConnection iDbConnection = session.Connection;  IDbTransaction iDbTransaction = iDbConnection.BeginTransaction();  return iDbTransaction;  }public static IDbDataParameter[] GetParameters(int paramsCount){IDbDataParameter[] idbParams = new IDbDataParameter[paramsCount];for (int i = 0; i < paramsCount; i++){idbParams[i] = new SqlParameter();}return idbParams;  }/// <summary>/// /// </summary>/// <param name="paramsCount"></param>public void CreateParameters(int paramsCount){Parameters = new IDbDataParameter[paramsCount];Parameters = GetParameters(paramsCount);}public void AddParameters(int index, string paramName, object objValue){if (index < Parameters.Length){Parameters[index].ParameterName = paramName;Parameters[index].Value = objValue;}}/// <summary>/// /// </summary>/// <param name="sessionFactory"></param>/// <param name="commandType"></param>/// <param name="commandText"></param>/// <returns></returns>public IDataReader ExecuteReader(NHibernate.ISessionFactory sessionFactory, CommandType commandType, string commandText){Command = sessionFactory.OpenSession().Connection.CreateCommand();Command.Connection = Connection;PrepareCommand(Command, Connection, Transaction, commandType, commandText, Parameters);DataReader = Command.ExecuteReader();Command.Parameters.Clear();return DataReader;}/// <summary>/// /// </summary>/// <param name="sessionFactory"></param>/// <param name="commandType"></param>/// <param name="commandText"></param>/// <returns></returns>public int ExecuteNonQuery(NHibernate.ISessionFactory sessionFactory, CommandType commandType, string commandText){Command = sessionFactory.OpenSession().Connection.CreateCommand(); PrepareCommand(Command, Connection, Transaction, commandType, commandText, Parameters);int returnValue = Command.ExecuteNonQuery();Command.Parameters.Clear();return returnValue;}public object ExecuteScalar(NHibernate.ISessionFactory sessionFactory, CommandType commandType, string commandText){Command = sessionFactory.OpenSession().Connection.CreateCommand(); PrepareCommand(Command, Connection, Transaction, commandType, commandText, Parameters);object returnValue = Command.ExecuteScalar();Command.Parameters.Clear();return returnValue;}/// <summary>/// /// </summary>/// <param name="sessionFactory"></param>/// <param name="commandType"></param>/// <param name="commandText"></param>/// <returns></returns>public DataSet ExecuteDataSet(NHibernate.ISessionFactory sessionFactory, CommandType commandType, string commandText){Command = sessionFactory.OpenSession().Connection.CreateCommand(); PrepareCommand(Command, Connection, Transaction, commandType, commandText, Parameters);IDbDataAdapter dataAdapter = new SqlDataAdapter(); //根据不同的数据库选择不同的数据库dataAdapter.SelectCommand = Command;DataSet dataSet = new DataSet();dataAdapter.Fill(dataSet);Command.Parameters.Clear();return dataSet;}/// <summary>/// /// </summary>/// <param name="sessionFactory"></param>/// <param name="commandType"></param>/// <param name="commandText"></param>/// <param name="sqlParams"></param>/// <returns></returns>public DataSet ExecuteDataSet(NHibernate.ISessionFactory sessionFactory, CommandType commandType, string commandText, IDbDataParameter[] sqlParams){Command = sessionFactory.OpenSession().Connection.CreateCommand();PrepareCommand(Command, Connection, Transaction, commandType, commandText, sqlParams);IDbDataAdapter dataAdapter = new SqlDataAdapter(); //根据不同的数据库选择不同的数据库dataAdapter.SelectCommand = Command;DataSet dataSet = new DataSet();dataAdapter.Fill(dataSet);Command.Parameters.Clear();return dataSet;} /// <summary>/// /// </summary>/// <param name="command"></param>/// <param name="commandParameters"></param>private void AttachParameters(IDbCommand command, IDbDataParameter[] commandParameters){foreach (IDbDataParameter idbParameter in commandParameters){if (idbParameter.Direction == ParameterDirection.InputOutput && idbParameter.Value == null){idbParameter.Value = DBNull.Value;}command.Parameters.Add(idbParameter);}}  /// <summary>/// /// </summary>/// <param name="command"></param>/// <param name="connection"></param>/// <param name="transaction"></param>/// <param name="commandType"></param>/// <param name="commandText"></param>/// <param name="commandParameters"></param>private void PrepareCommand(IDbCommand command, IDbConnection connection, IDbTransaction transaction,CommandType commandType, string commandText, IDbDataParameter[] commandParameters){command.Connection = connection;command.CommandText = commandText;command.CommandType = commandType;if (transaction != null){command.Transaction = transaction;}if (commandParameters != null){AttachParameters(command, commandParameters);}}  

  

转载于:https://www.cnblogs.com/geovindu/p/5633828.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/424103.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

第六课 多算法组合与模型调优

本系列是七月算法机器学习课程笔记 文章目录1 前序工作流程1.1 数据处理1.2 特征工程1.3 模型选择1.4 交叉验证1.5 寻找最佳超参数2 模型优化2.1 模型状态2.2 模型优化12.3 模型优化22.4 模型优化32.5 模型优化4&#xff1a;模型融合2.5.1 bagging2.5.2 staking2.5.3 adaboost2…

第一百二十一期:当新闻报道用上AR 技术,能为读者带来什么?

「有一种名为记忆宫殿的记忆术&#xff0c;要点就是在人脑内建立起虚拟的空间场景&#xff0c;并把各种信息与空间产生联系。如果我们也能为每一起新闻建立起空间的概念&#xff0c;显然也会给读者带来更深刻的印象。」 作者&#xff1a;木斯 大部分新闻都拥有不同的切入视角…

第七章 scikit-learn与机器学习实战

文章目录1 scikit-learn2 一个项目实战2.1 项目目标2.2 划定问题2.3 选择性能指标2.4 核实假设2.5 获取数据2.6 数据探索和可视化、发现规律2.7 为机器学习算法准备数据2.8 选择并且训练模型2.9 模型微调2.10 测试集上测试1 scikit-learn 导航页与算法指南 API&#xff1a;数据…

Erlang注册进程名称-tut16.erl

作 w3cschool erlang 的练习 --------- 1 -module(tut16).2 3 -export([start/0, ping/1, pong/0]).4 5 %% Erlang 注册进程名称6 7 %% ping 进程必须通过某种途径 获得 pong 进程的进程标识符后 8 %% 才能将消息发送给 pong 进程9 10 %% Erlang 提供了 为每个进程提供一个名称…

第一百二十二期:大数据分析:红包先抢好,还是后抢好

本文用matlab程序&#xff0c;模拟微信给10个人发红包&#xff0c;设定次数1亿次&#xff0c;统计每个人抢到的红包&#xff0c;最佳手气和最差手气次数&#xff0c;用以分析红包是应该先抢还是后抢? 作者&#xff1a;景因分析 本文用matlab程序&#xff0c;模拟微信给10个人…

Linux重定向的理解

1 /*2 重定向的实例3 dup2函数4 5  利用filefd来代替STDOUT(标准输出流)&#xff0c;write写入filefd的数据&#xff0c;重定向写出到STDOUT中&#xff1b;6 */7 8 #include <stdio.h>9 #include <sys/stat.h> 10 #include <string.h> 11 #include …

spring mvc学习(30):sessionatrribute存储session数据

创建maven项目就不说了&#xff0c;需要的找我前面的博客 pom.xml文件 <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation"http://maven.apache.org/POM/4.0.0 http…

验证码

金讯教育有一节课讲的是验证码;代码如下&#xff1a; html: <label><input type"text" /><span id"yz" style" background:url(1.png) -10px -15px;width:80px;font-style: italic; height: 20px;border: 1px solid black;display: in…

第九章 隐马尔科夫模型HMM

文章目录1 隐马尔科夫模型定义2 概率计算算法2.1 前向概率2.2 概率计算3 学习算法3.1 EM算法3.2EM在HMM4 预测算法1 隐马尔科夫模型定义 隐马尔科夫模型是一个seq2seq模型。例如词性标注。 时间序列t1t2t3状态序列代词动词名词观察序列我爱机器学习 能够看到的&#xff0c;例…

spring mvc学习(31):原生api

创建maven项目就不说了&#xff0c;需要的找我前面的博客 pom.xml文件 <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation"http://maven.apache.org/POM/4.0.0 http…

如何使用设计模式来构造系统--(7)

(声明:本系列所用的模式都来自GOF23中&#xff0c;本系列并不是讲23种经典设计模式&#xff0c;而是如何去使用这些模式) 在前面的文章中,我们设计完成了员工工资,福利以及按照部门来区分员工,以及遍历统计部门人员成本等业务逻辑,这些设计基本上可以满足我们所设定的场景的…

spring mvc学习(32):原生代码导入

第一种方法 1点击项目--右键---preferences(添加build path) 勾上 第二种方法 2配置pom.xml <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</…

深度学习03-CNN 应用

说明&#xff1a;本系列是七月算法深度学习课程的学习笔记 文章目录1 概述2 图片识别定位3 物体监测3.1 选择性搜索3.2 R-CNN3.3 Fast R-CNN3.4 Faster R-CNN4 语义分割4.1 滑窗处理4.2全卷积神经网络5 代码1 概述 CNN主要任务包含物体识别定位、物体识别、图像分割。 图片识…

【转帖】windows命令行中java和javac、javap使用详解(java编译命令)

windows命令行中java和javac、javap使用详解(java编译命令) 更新时间&#xff1a;2014年03月23日 11:53:15 作者&#xff1a; 我要评论 http://www.jb51.net/article/48380.htm学习一下java 最近重新复习了一下java基础&#xff0c;这里便讲讲对于一个类文件如何编译、运行…

第六课 从词向量到NLP分类问题

文章目录1 nlp的常见任务2 词向量表示2.1 离散表示2.2 分布式表示2.3 NNLM(2013年)2.3.1模型2.3.2特点2.4 Word2Vector&#xff1a;CBOW连续词袋2.4.1 样本处理2.4.2 结构2.4.3 CBOW&#xff1a;层次softmax2.4.4 CBOW&#xff1a;负例采样2.4.5 Word2Vec&#xff1a;skip-gram…

spring mvc学习(34):restful的delete

创建maven项目就不说了&#xff0c;需要的找我前面的博客 pom.xml文件 <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation"http://maven.apache.org/POM/4.0.0 http…

热度3年猛增20倍,Serverless云开发的技术架构全解析

『 作为一个不断发展的新兴技术&#xff0c; Serverless 热度的制高点已然到来。』 或许&#xff0c;Google Trends 所显示的 3 年猛增 20 倍的“ Serverless ” 搜索量&#xff0c;可以佐证 Serverless 在整个行业中的火爆程度。 不仅如此&#xff0c;据 KBV 研究公司新发布的…

第七课 循环神经网络与自然语言处理

文章目录1 循环神经网络1.1 场景与多种应用1.2 RNN网络结构1.2.1为什么需要RNN1.2.2 RNN 结构1.3 多种RNN1.4 BPTT算法1.5 生成模型与图像描述2 LSTM2.1 LSTM2.2 GRU1 循环神经网络 1.1 场景与多种应用 1 模仿论文生成 2 模仿linux内核编写代码 3 模仿小四写论文 4 机器翻译 …

第十二题:设int x=1,float y=2,则表达式x/y的值是:

第十二题 设int x1,float y2,则表达式x/y的值是&#xff1a;&#xff08;&#xff09; A 0 B 1 C 2 D 以上都不是 懵逼树上懵逼果&#xff0c;懵逼树下你和我 首先看到这道题&#xff0c;我是懵逼和绝望的。 首先我们打开评论&#xff0c;看看谁的赞最多&#xff0c;拿…

Linux 安装 lanmp

Lanmp介绍 lanmp一键安装包是wdlinux官网2010年底开始推出的web应用环境的快速简易安装包. 执行一个脚本&#xff0c;整个环境就安装完成就可使用&#xff0c;快速,方便易用,安全稳定 lanmp一键安装包是用shell脚本编写,且是开源的,你也可以根据业务需求,做相应的调整,来安装自…