fix(#IX8UT): PetaPoco.Mapper.Register抛异常
#Comment comment #IX8UT #Issue close https://gitee.com/LongbowEnterprise/dashboard/issues?id=IX8UT
This commit is contained in:
parent
dabeff42bc
commit
e0b4e113ec
|
@ -9,6 +9,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class DbManager
|
public static class DbManager
|
||||||
{
|
{
|
||||||
|
private static readonly object _locker = new object();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -16,7 +17,13 @@ namespace Bootstrap.DataAccess
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IDatabase Create(string connectionName = null, bool keepAlive = false)
|
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);
|
var db = Longbow.Data.DbManager.Create(connectionName, keepAlive);
|
||||||
db.ExceptionThrown += (sender, args) => args.Exception.Log(new NameValueCollection() { ["LastCmd"] = db.LastCommand });
|
db.ExceptionThrown += (sender, args) => args.Exception.Log(new NameValueCollection() { ["LastCmd"] = db.LastCommand });
|
||||||
return db;
|
return db;
|
||||||
|
|
Loading…
Reference in New Issue