企业库创建 Database 实例的两种方式:
需要引入DLL文件:
Microsoft.Practices.ServiceLocation.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.Unity.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
其一 |
using System.Data.Common; using Microsoft.Practices.EnterpriseLibrary.Data; using Microsoft.Practices.EnterpriseLibrary.Common.Configuration; using Microsoft.Practices .EnterpriseLibrary.Common; using System.Data; using System.Data.SqlClient; public class DataHelper{ /// <summary> /// 数据库持久对象 /// </summary> public static readonly Database DatabaseObj = EnterpriseLibraryContainer.Current.GetInstance < Database > ();}
其二 |
public static Database DatabaseObj = DatabaseFactory.CreateDatabase();