using PetaPoco; using System; using System.Collections.Specialized; namespace Bootstrap.DataAccess { /// /// 数据库对象管理类 /// public static class DbManager { /// /// 创建 IDatabase 实例方法 /// /// /// /// public static IDatabase Create(string connectionName = null, bool keepAlive = false) { if (Mappers.GetMapper(typeof(Exceptions), null) == null) Mappers.Register(typeof(Exceptions).Assembly, new BootstrapDataAccessConventionMapper()); var db = Longbow.Data.DbManager.Create(connectionName, keepAlive); db.ExceptionThrown += (sender, args) => args.Exception.Log(new NameValueCollection() { ["LastCmd"] = db.LastCommand }); return db; } } }