refactor(project): 根据最新组件重构代码
Longbow.Dat 2.3.0 Bootstrap.Security.DataAccess 2.2.0 PetaPoco.Compiled 6.0.403 PetaPoco.Extensions 1.0.4 增加BootstrapDataAccessConventionMapper适应BA数据库对应关系
This commit is contained in:
parent
3800ffc98a
commit
e96192bded
|
@ -11,9 +11,9 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.1.0" />
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.0" />
|
||||
<PackageReference Include="Longbow.Cache" Version="2.2.9" />
|
||||
<PackageReference Include="Longbow.Data" Version="2.2.8" />
|
||||
<PackageReference Include="Longbow.Data" Version="2.3.0" />
|
||||
<PackageReference Include="Longbow.Web" Version="2.2.11" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Data;
|
||||
using PetaPoco;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
|
@ -11,14 +11,15 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.1.0" />
|
||||
<PackageReference Include="Longbow.Data" Version="2.2.8" />
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.0" />
|
||||
<PackageReference Include="Longbow.Data" Version="2.3.0" />
|
||||
<PackageReference Include="Longbow.Logging" Version="2.2.6" />
|
||||
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
|
||||
<PackageReference Include="Longbow.Web" Version="2.2.11" />
|
||||
<PackageReference Include="Longbow.Cache" Version="2.2.9" />
|
||||
<PackageReference Include="Longbow" Version="2.2.9" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
|
||||
<PackageReference Include="PetaPoco.Extensions" Version="1.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
using PetaPoco;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
internal class BootstrapDataAccessConventionMapper : IMapper
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public BootstrapDataAccessConventionMapper()
|
||||
{
|
||||
_mapper = new ConventionMapper();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="pocoProperty"></param>
|
||||
/// <returns></returns>
|
||||
public ColumnInfo GetColumnInfo(PropertyInfo pocoProperty) => _mapper.GetColumnInfo(pocoProperty);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="targetProperty"></param>
|
||||
/// <param name="sourceType"></param>
|
||||
/// <returns></returns>
|
||||
public Func<object, object> GetFromDbConverter(PropertyInfo targetProperty, Type sourceType) => _mapper.GetFromDbConverter(targetProperty, sourceType);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="pocoType"></param>
|
||||
/// <returns></returns>
|
||||
public TableInfo GetTableInfo(Type pocoType)
|
||||
{
|
||||
var ti = _mapper.GetTableInfo(pocoType);
|
||||
ti.AutoIncrement = true;
|
||||
return ti;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sourceProperty"></param>
|
||||
/// <returns></returns>
|
||||
public Func<object, object> GetToDbConverter(PropertyInfo sourceProperty) => _mapper.GetToDbConverter(sourceProperty);
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
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;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Data;
|
||||
using PetaPoco;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
Loading…
Reference in New Issue