getstoredproccommand(“procedurename”,new object [1])在Microsoft.Practices.EnterpriseLibrary.Data.dll中
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了getstoredproccommand(“procedurename”,new object [1])在Microsoft.Practices.EnterpriseLibrary.Data.dll中相关的知识,希望对你有一定的参考价值。
public static IEnumerable<PortalList> GetAll()
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand objComm = db.GetStoredProcCommand("package
name.procedurename", new object[1]);
var result = new List<PortalList>();
using (IDataReader rdr = db.ExecuteReader(objComm))
{
while (rdr.Read())
{
result.Add(Construct(rdr));
}
}
return result;
}
我的商店程序是这样的
PROCEDURE PRC_PROCEDURE (resultset_out OUT TYPES.cursorType)
AS
BEGIN
OPEN resultset_out FOR SELECT * FROM PORTALLISTS;
END PRC_PORTALLISTS_GETALL;
我在这行DbCommand objComm = db.GetStoredProcCommand("package name.procedurename", new object[1]);
有错误
如果我这样做
DbCommand objComm = db.GetStoredProcCommand("package name.procedurename");
错误消失,但后来我使用[Exception thrown: 'System.AccessViolationException' in Microsoft.Practices.EnterpriseLibrary.Data.dll]
在这一行面临相同的error(IDataReader rdr = db.ExecuteReader(objComm))
。我使用的是dot.net framework 4和Microsoft.Practices.EnterpriseLibrary.Data.dll版本是5.0.0.0。你们能帮助我吗?
在portallistservices.cs文件中我有这个
public static IEnumerable<PortalList> GetAll()
{
return GetAll(true);
}
private static IEnumerable<PortalList> GetAll(bool forceDataReload)
{
const string cacheKey = "PortalListService_GetAll";
IEnumerable<PortalList> result = null;
if (!forceDataReload)
result = GetFromCache(cacheKey);
if (result == null)
{
result = PortalListRepository.GetAll();
AddToCache(cacheKey, result);
}
return result;
}
你有resultset_out
作为param,你可以通过你的params如下
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
// Output parameters specify the size of the return data.
db.AddOutParameter(dbCommand, "resultset_out", DbType.Object, Int32.MaxValue);
ref https://msdn.microsoft.com/en-us/library/ff647630.aspx
以上是关于getstoredproccommand(“procedurename”,new object [1])在Microsoft.Practices.EnterpriseLibrary.Data.dll中的主要内容,如果未能解决你的问题,请参考以下文章