这当前项目,我被分配使用的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但也许新版本让事情变得更简单(我听说过团结一些很好的东西)。