-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
2,458 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using System.Data; | ||
|
||
namespace Util.Data; | ||
namespace Util.Data; | ||
|
||
/// <summary> | ||
/// 数据库信息 | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Util.Data.Dapper.Oracle/05-Util.Data.Dapper.Oracle.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(NetTargetFramework)</TargetFramework> | ||
<PackageIcon>icon.jpg</PackageIcon> | ||
<AssemblyName>Util.Data.Dapper.Oracle</AssemblyName> | ||
<RootNamespace>Util.Data.Dapper</RootNamespace> | ||
<Description>Util.Data.Dapper.Oracle是Util应用框架基于Dapper的数据访问封装类库,用于处理Oracle数据库</Description> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<OutputPath></OutputPath> | ||
<DocumentationFile>.\obj\Debug\$(NetTargetFramework)\Util.Data.Dapper.Oracle.xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<OutputPath></OutputPath> | ||
<DocumentationFile>.\obj\Release\$(NetTargetFramework)\Util.Data.Dapper.Oracle.xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\build\icon.jpg"> | ||
<Pack>True</Pack> | ||
<Visible>False</Visible> | ||
<PackagePath></PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.120" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Util.Data.Dapper.Core\01-Util.Data.Dapper.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
35 changes: 35 additions & 0 deletions
35
src/Util.Data.Dapper.Oracle/Infrastructure/OracleDapperServiceRegistrar.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Util.Data.Dapper.TypeHandlers; | ||
using Util.Infrastructure; | ||
|
||
namespace Util.Data.Dapper.Infrastructure; | ||
|
||
/// <summary> | ||
/// Oracle Dapper服务注册器 | ||
/// </summary> | ||
public class OracleDapperServiceRegistrar : IServiceRegistrar { | ||
/// <summary> | ||
/// 获取服务名 | ||
/// </summary> | ||
public static string ServiceName => "Util.Data.Dapper.Infrastructure.OracleDapperServiceRegistrar"; | ||
|
||
/// <summary> | ||
/// 排序号 | ||
/// </summary> | ||
public int OrderId => 812; | ||
|
||
/// <summary> | ||
/// 是否启用 | ||
/// </summary> | ||
public bool Enabled => ServiceRegistrarConfig.IsEnabled( ServiceName ); | ||
|
||
/// <summary> | ||
/// 注册服务 | ||
/// </summary> | ||
/// <param name="serviceContext">服务上下文</param> | ||
public Action Register( ServiceContext serviceContext ) { | ||
SqlMapper.RemoveTypeMap( typeof( Guid ) ); | ||
SqlMapper.RemoveTypeMap( typeof( Guid? ) ); | ||
SqlMapper.AddTypeHandler( typeof( Guid ), new GuidTypeHandler() ); | ||
return null; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Util.Data.Dapper.Oracle/Infrastructure/ServiceRegistrarConfigExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Util.Infrastructure; | ||
|
||
namespace Util.Data.Dapper.Infrastructure; | ||
|
||
/// <summary> | ||
/// Oracle Dapper服务注册器配置扩展 | ||
/// </summary> | ||
public static class ServiceRegistrarConfigExtensions { | ||
/// <summary> | ||
/// 启用Oracle Dapper服务注册器 | ||
/// </summary> | ||
/// <param name="config">服务注册器配置</param> | ||
public static ServiceRegistrarConfig EnableOracleDapperServiceRegistrar( this ServiceRegistrarConfig config ) { | ||
ServiceRegistrarConfig.Enable( OracleDapperServiceRegistrar.ServiceName ); | ||
return config; | ||
} | ||
|
||
/// <summary> | ||
///禁用Oracle Dapper服务注册器 | ||
/// </summary> | ||
/// <param name="config">服务注册器配置</param> | ||
public static ServiceRegistrarConfig DisableOracleDapperServiceRegistrar( this ServiceRegistrarConfig config ) { | ||
ServiceRegistrarConfig.Disable( OracleDapperServiceRegistrar.ServiceName ); | ||
return config; | ||
} | ||
} |
127 changes: 127 additions & 0 deletions
127
src/Util.Data.Dapper.Oracle/Sql/AppBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
using Util.Configs; | ||
using Util.Data.Sql; | ||
|
||
namespace Util.Data.Dapper.Sql; | ||
|
||
/// <summary> | ||
/// Oracle数据库操作扩展 | ||
/// </summary> | ||
public static class AppBuilderExtensions { | ||
|
||
#region AddOracleSqlQuery(配置Oracle Sql查询对象) | ||
|
||
/// <summary> | ||
/// 配置Oracle Sql查询对象 | ||
/// </summary> | ||
/// <param name="builder">应用生成器</param> | ||
public static IAppBuilder AddOracleSqlQuery( this IAppBuilder builder ) { | ||
return builder.AddOracleSqlQuery( "" ); | ||
} | ||
|
||
/// <summary> | ||
/// 配置Oracle Sql查询对象 | ||
/// </summary> | ||
/// <param name="builder">应用生成器</param> | ||
/// <param name="connection">数据库连接字符串</param> | ||
public static IAppBuilder AddOracleSqlQuery( this IAppBuilder builder, string connection ) { | ||
return builder.AddOracleSqlQuery<ISqlQuery, OracleSqlQuery>( connection ); | ||
} | ||
|
||
/// <summary> | ||
/// 配置Oracle Sql查询对象 | ||
/// </summary> | ||
/// <param name="builder">应用生成器</param> | ||
/// <param name="setupAction">配置操作</param> | ||
public static IAppBuilder AddOracleSqlQuery( this IAppBuilder builder, Action<SqlOptions> setupAction ) { | ||
return builder.AddOracleSqlQuery<ISqlQuery, OracleSqlQuery>( setupAction ); | ||
} | ||
|
||
/// <summary> | ||
/// 配置Oracle Sql查询对象 | ||
/// </summary> | ||
/// <param name="builder">应用生成器</param> | ||
/// <param name="connection">数据库连接字符串</param> | ||
public static IAppBuilder AddOracleSqlQuery<TService, TImplementation>( this IAppBuilder builder, string connection ) | ||
where TService : ISqlQuery | ||
where TImplementation : OracleSqlQueryBase, TService { | ||
return builder.AddOracleSqlQuery<TService, TImplementation>( t => t.ConnectionString( connection ) ); | ||
} | ||
|
||
/// <summary> | ||
/// 配置Oracle Sql查询对象 | ||
/// </summary> | ||
/// <param name="builder">应用生成器</param> | ||
/// <param name="setupAction">配置操作</param> | ||
public static IAppBuilder AddOracleSqlQuery<TService, TImplementation>( this IAppBuilder builder, Action<SqlOptions> setupAction ) | ||
where TService : ISqlQuery | ||
where TImplementation : OracleSqlQueryBase, TService { | ||
var options = new SqlOptions<TImplementation>(); | ||
setupAction?.Invoke( options ); | ||
builder.CheckNull( nameof( builder ) ); | ||
builder.Host.ConfigureServices( ( context, services ) => { | ||
services.TryAddTransient( typeof( TService ), typeof( TImplementation ) ); | ||
services.TryAddSingleton( typeof( SqlOptions<TImplementation> ), ( sp ) => options ); | ||
} ); | ||
return builder; | ||
} | ||
|
||
#endregion | ||
|
||
#region AddOracleSqlExecutor(配置Oracle Sql执行器) | ||
|
||
/// <summary> | ||
/// 配置Oracle Sql执行器 | ||
/// </summary> | ||
/// <param name="builder">应用生成器</param> | ||
public static IAppBuilder AddOracleSqlExecutor( this IAppBuilder builder ) { | ||
return builder.AddOracleSqlExecutor( "" ); | ||
} | ||
|
||
/// <summary> | ||
/// 配置Oracle Sql执行器 | ||
/// </summary> | ||
/// <param name="builder">应用生成器</param> | ||
/// <param name="connection">数据库连接字符串</param> | ||
public static IAppBuilder AddOracleSqlExecutor( this IAppBuilder builder, string connection ) { | ||
return builder.AddOracleSqlExecutor<ISqlExecutor, OracleSqlExecutor>( connection ); | ||
} | ||
|
||
/// <summary> | ||
/// 配置Oracle Sql执行器 | ||
/// </summary> | ||
/// <param name="builder">应用生成器</param> | ||
/// <param name="setupAction">配置操作</param> | ||
public static IAppBuilder AddOracleSqlExecutor( this IAppBuilder builder, Action<SqlOptions> setupAction ) { | ||
return builder.AddOracleSqlExecutor<ISqlExecutor, OracleSqlExecutor>( setupAction ); | ||
} | ||
|
||
/// <summary> | ||
/// 配置Oracle Sql执行器 | ||
/// </summary> | ||
/// <param name="builder">应用生成器</param> | ||
/// <param name="connection">数据库连接字符串</param> | ||
public static IAppBuilder AddOracleSqlExecutor<TService, TImplementation>( this IAppBuilder builder, string connection ) | ||
where TService : ISqlExecutor | ||
where TImplementation : OracleSqlExecutorBase, TService { | ||
return builder.AddOracleSqlExecutor<TService, TImplementation>( t => t.ConnectionString( connection ) ); | ||
} | ||
|
||
/// <summary> | ||
/// 配置Oracle Sql执行器 | ||
/// </summary> | ||
/// <param name="builder">应用生成器</param> | ||
/// <param name="setupAction">配置操作</param> | ||
public static IAppBuilder AddOracleSqlExecutor<TService, TImplementation>( this IAppBuilder builder, Action<SqlOptions> setupAction ) | ||
where TService : ISqlExecutor | ||
where TImplementation : OracleSqlExecutorBase, TService { | ||
var options = new SqlOptions<TImplementation>(); | ||
setupAction?.Invoke( options ); | ||
builder.Host.ConfigureServices( ( context, services ) => { | ||
services.TryAddTransient( typeof( TService ), typeof( TImplementation ) ); | ||
services.TryAddSingleton( typeof( SqlOptions<TImplementation> ), ( sp ) => options ); | ||
} ); | ||
return builder; | ||
} | ||
|
||
#endregion | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Util.Data.Dapper.Oracle/Sql/Builders/OracleColumnCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Util.Data.Sql.Builders.Caches; | ||
|
||
namespace Util.Data.Dapper.Sql.Builders; | ||
|
||
/// <summary> | ||
/// Oracle列缓存 | ||
/// </summary> | ||
public class OracleColumnCache : ColumnCacheBase { | ||
/// <summary> | ||
/// 列名缓存 | ||
/// </summary> | ||
private readonly ConcurrentDictionary<int, string> _cache; | ||
|
||
/// <summary> | ||
/// 封闭构造方法 | ||
/// </summary> | ||
private OracleColumnCache() : base( OracleDialect.Instance ) { | ||
_cache = new ConcurrentDictionary<int, string>(); | ||
} | ||
|
||
/// <summary> | ||
/// Oracle列缓存实例 | ||
/// </summary> | ||
public static readonly IColumnCache Instance = new OracleColumnCache(); | ||
|
||
/// <inheritdoc /> | ||
public override string GetSafeColumns( string columns ) { | ||
return _cache.GetOrAdd( columns.GetHashCode(), key => NormalizeColumns( columns ) ); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override string GetSafeColumn( string column ) { | ||
return _cache.GetOrAdd( column.GetHashCode(), key => NormalizeColumn( column ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Util.Data.Sql.Builders; | ||
using Util.Data.Sql.Builders.Core; | ||
|
||
namespace Util.Data.Dapper.Sql.Builders; | ||
|
||
/// <summary> | ||
/// Oracle方言 | ||
/// </summary> | ||
public class OracleDialect : DialectBase { | ||
/// <summary> | ||
/// 封闭构造方法 | ||
/// </summary> | ||
private OracleDialect() { | ||
} | ||
|
||
/// <summary> | ||
/// Oracle方言实例 | ||
/// </summary> | ||
public static readonly IDialect Instance = new OracleDialect(); | ||
|
||
/// <inheritdoc /> | ||
public override string GetOpeningIdentifier() { | ||
return "\""; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override string GetClosingIdentifier() { | ||
return "\""; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override string GetPrefix() { | ||
return ":"; | ||
} | ||
} |
Oops, something went wrong.