From e0b4e113ec32ca5d836260b1ab53fa0589229884 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 30 May 2019 21:56:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(#IX8UT):=20PetaPoco.Mapper.Register?= =?UTF-8?q?=E6=8A=9B=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment comment #IX8UT #Issue close https://gitee.com/LongbowEnterprise/dashboard/issues?id=IX8UT --- Bootstrap.DataAccess/DbManager.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Bootstrap.DataAccess/DbManager.cs b/Bootstrap.DataAccess/DbManager.cs index 0ea0ef27..d1c407f9 100644 --- a/Bootstrap.DataAccess/DbManager.cs +++ b/Bootstrap.DataAccess/DbManager.cs @@ -9,6 +9,7 @@ namespace Bootstrap.DataAccess /// public static class DbManager { + private static readonly object _locker = new object(); /// /// /// @@ -16,7 +17,13 @@ namespace Bootstrap.DataAccess /// public static IDatabase Create(string connectionName = null, bool keepAlive = false) { - if (Mappers.GetMapper(typeof(Exceptions), null) == null) Mappers.Register(typeof(Exceptions).Assembly, new BootstrapDataAccessConventionMapper()); + if (Mappers.GetMapper(typeof(Exceptions), null) == null) + { + lock (_locker) + { + 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;