Nhibernate/Hibernate 使用多参数存儲過程 出現could not execute query,Could not locate named parameter等錯誤解決

时间:2021-10-09 23:22:32

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Mrp.Domain" assembly="Mrp.Domain"> <class name="GetQpmrpWorkDomain">
<id name="ActualStart">
</id>
<property name="ActualFinish" column="ActualFinish"/>
<property name="status" column="status"/>
</class>
<sql-query name="GetQpmrpWorkDomainListByParam">
<return alias="GetQpmrpWorkDomain" class="Mrp.Domain.GetQpmrpWorkDomain"/>
<![CDATA[
exec dbo.p_pms_get_qpmrp_work_info :projectid,:taskid,:info_code,:expandargs,:p_companyid
]]>
</sql-query>
</hibernate-mapping>
using Mrp.IBLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Data;
using ServiceLocation;
using Mrp.Domain; namespace Mrp.BLL
{
public class GetQpmrpWorkManager : IGetQpmrpWorkManager
{
IDataAccess da = Locator.Current.GetObject<IDataAccess>(); public IList<GetQpmrpWorkDomain> GetList(string projectid,string taskid,string info_code,string expandargs,string p_companyid)
{
projectid = "";
NamedQuery namedQuery = new NamedQuery("GetQpmrpWorkDomainListByParam");
namedQuery.AddParameter("projectid", projectid);
namedQuery.AddParameter("taskid", taskid);
namedQuery.AddParameter("info_code", info_code);
namedQuery.AddParameter("expandargs", expandargs);
namedQuery.AddParameter("p_companyid", p_companyid);
return da.GetList<GetQpmrpWorkDomain>(namedQuery);
}
}
}