這當前項目,我被分配使用的3.1版水平MS企業庫的最新版本不兼容:與舊版本像3.1
Microsoft.Practices.EnterpriseLibrary.Common;
Microsoft.Practices.EnterpriseLibrary.Data;
當我嘗試去了解更多的功能Ent Lib,我遇到了很多關於各種版本的文章和文檔(我認爲是3.1,4.0和5.0)。
一般來說,新版本可以使用爲早期版本的Ent Lib編寫的應用程序代碼嗎?我還沒有調查過我繼承的這個應用程序中的所有源代碼,但我認爲只使用了數據訪問應用程序塊的「基礎」。下面是一段典型的代碼塊:
public override List<Erx.Action> GetAll(bool bIsActive)
{
Database db = null;
DbCommand cmd = null;
List<Erx.Action> lst = null;
IDataReader iRdr = null;
try
{
db = DatabaseFactory.CreateDatabase();
cmd = db.GetStoredProcCommand("Mst_GetAllCorrectiveAction");
db.AddInParameter(cmd, "@CorrectiveActionID", DbType.Int32, -1);
db.AddInParameter(cmd, "@IsActive", DbType.Boolean, bIsActive);
iRdr = db.ExecuteReader(cmd);
lst = new List<Erx.Action>();
while (iRdr.Read())
{
Action objAction = new Action();
objAction.CorrectiveAction = iRdr["CorrectiveAction"].ToString();
objAction.CorrectiveActionID = int.Parse(iRdr["CorrectiveActionID"].ToString());
objAction.IsActive = (bool)iRdr["IsActive"];
lst.Add(objAction);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
db = null;
iRdr.Close();
if (cmd != null)
{
cmd.Dispose(); cmd = null;
}
}
return lst;
}
坦率地說,這似乎並沒有提供遠遠超出普通ADO.Net但也許新版本讓事情變得更簡單(我聽說過團結一些很好的東西)。