Skip to content

Commit 082dcf1

Browse files
committed
- 增加 FreeSql.Provider.Custom 自定义适配访问任何数据库;
1 parent 7aedc52 commit 082dcf1

File tree

18 files changed

+1509
-193
lines changed

18 files changed

+1509
-193
lines changed

FreeSql.DbContext/FreeSql.DbContext.xml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.KingbaseES
9191
EndProject
9292
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.Firebird", "Providers\FreeSql.Provider.Firebird\FreeSql.Provider.Firebird.csproj", "{101B11D2-7780-4E14-9B72-77F5D69B3DF9}"
9393
EndProject
94+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.Custom", "Providers\FreeSql.Provider.Custom\FreeSql.Provider.Custom.csproj", "{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}"
95+
EndProject
9496
Global
9597
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9698
Debug|Any CPU = Debug|Any CPU
@@ -557,6 +559,18 @@ Global
557559
{101B11D2-7780-4E14-9B72-77F5D69B3DF9}.Release|x64.Build.0 = Release|Any CPU
558560
{101B11D2-7780-4E14-9B72-77F5D69B3DF9}.Release|x86.ActiveCfg = Release|Any CPU
559561
{101B11D2-7780-4E14-9B72-77F5D69B3DF9}.Release|x86.Build.0 = Release|Any CPU
562+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
563+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
564+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Debug|x64.ActiveCfg = Debug|Any CPU
565+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Debug|x64.Build.0 = Debug|Any CPU
566+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Debug|x86.ActiveCfg = Debug|Any CPU
567+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Debug|x86.Build.0 = Debug|Any CPU
568+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
569+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Release|Any CPU.Build.0 = Release|Any CPU
570+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Release|x64.ActiveCfg = Release|Any CPU
571+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Release|x64.Build.0 = Release|Any CPU
572+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Release|x86.ActiveCfg = Release|Any CPU
573+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1}.Release|x86.Build.0 = Release|Any CPU
560574
EndGlobalSection
561575
GlobalSection(SolutionProperties) = preSolution
562576
HideSolutionNode = FALSE
@@ -589,6 +603,7 @@ Global
589603
{3D2BD8EC-253A-437F-B4C8-74BC0D91429B} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
590604
{CDD6A896-F6DF-44CB-B430-06B383916EB0} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
591605
{101B11D2-7780-4E14-9B72-77F5D69B3DF9} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
606+
{0DBAA21C-39B2-4AAD-A43D-88E67ED239D1} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
592607
EndGlobalSection
593608
GlobalSection(ExtensibilityGlobals) = postSolution
594609
SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98}

FreeSql/DataType.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ public enum DataType {
5454
/// <summary>
5555
/// Firebird 是一个跨平台的关系数据库,能作为多用户环境下的数据库服务器运行,也提供嵌入式数据库的实现
5656
/// </summary>
57-
Firebird
57+
Firebird,
58+
59+
/// <summary>
60+
/// 自定义适配器,访问任何数据库<para></para>
61+
/// 注意:该类型不提供 DbFirst/CodeFirst 功能
62+
/// </summary>
63+
Custom
5864
}
5965
}

FreeSql/FreeSql.xml

Lines changed: 6 additions & 183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql/FreeSqlBuilder.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ public IFreeSql<TMark> Build<TMark>()
256256
if (type == null) throwNotFind("FreeSql.Provider.Firebird.dll", "FreeSql.Firebird.FirebirdProvider<>");
257257
break;
258258

259+
case DataType.Custom:
260+
type = Type.GetType("FreeSql.Custom.CustomProvider`1,FreeSql.Provider.Custom")?.MakeGenericType(typeof(TMark));
261+
if (type == null) throwNotFind("FreeSql.Provider.Custom.dll", "FreeSql.Custom.CustomProvider<>");
262+
break;
263+
259264
default: throw new Exception("未指定 UseConnectionString 或者 UseConnectionFactory");
260265
}
261266
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using FreeSql.Internal;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Data;
5+
using System.Text;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
9+
namespace FreeSql.Custom
10+
{
11+
12+
class CustomDelete<T1> : Internal.CommonProvider.DeleteProvider<T1>
13+
{
14+
public CustomDelete(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
15+
: base(orm, commonUtils, commonExpression, dywhere)
16+
{
17+
}
18+
19+
public override List<T1> ExecuteDeleted() => throw new NotImplementedException("FreeSql.Provider.Custom 未实现该功能");
20+
21+
#if net40
22+
#else
23+
public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException("FreeSql.Provider.Custom 未实现该功能");
24+
#endif
25+
}
26+
}

0 commit comments

Comments
 (0)