From f4092607c99f001f7b0e62b9886a12e26a2351e8 Mon Sep 17 00:00:00 2001 From: sunkaixuna <610262374@qq.com> Date: Tue, 25 Jan 2022 17:25:28 +0800 Subject: [PATCH] Support custom database --- Src/Asp.Net/SqlSugar/Enum/DbType.cs | 5 ++++- .../SqlSugar/Infrastructure/InstanceFactory.cs | 14 +++++++++++++- .../Realization/Custom/CustomProvider.cs | 16 ++++++++++++++++ Src/Asp.Net/SqlSugar/SqlSugar.csproj | 1 + 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 Src/Asp.Net/SqlSugar/Realization/Custom/CustomProvider.cs diff --git a/Src/Asp.Net/SqlSugar/Enum/DbType.cs b/Src/Asp.Net/SqlSugar/Enum/DbType.cs index bac17890e..b69d5140e 100644 --- a/Src/Asp.Net/SqlSugar/Enum/DbType.cs +++ b/Src/Asp.Net/SqlSugar/Enum/DbType.cs @@ -14,6 +14,9 @@ namespace SqlSugar PostgreSQL, Dm, Kdbndp, - Oscar + Oscar, + MySqlConnector, + Access, + Custom=900 } } diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs b/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs index 049b07468..ca1a45f2a 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs @@ -25,13 +25,25 @@ namespace SqlSugar { return new SqlServerQueryable(); } - else if (currentConnectionConfig.DbType == DbType.MySql) + else if (currentConnectionConfig.DbType == DbType.MySql) { return new MySqlQueryable(); } else if (currentConnectionConfig.DbType == DbType.PostgreSQL) { return new PostgreSQLQueryable(); + } + else if (currentConnectionConfig.DbType == DbType.MySqlConnector) + { + return CustomProvider.GetQueryable("MySql", "SqlSugar.MySqlConnector"); + } + else if (currentConnectionConfig.DbType == DbType.Access) + { + return CustomProvider.GetQueryable("MySql", "SqlSugar.Access"); + } + else if (currentConnectionConfig.DbType == DbType.Custom) + { + return CustomProvider.GetQueryable("DbType.Custom", "DbType.Custom"); } else { diff --git a/Src/Asp.Net/SqlSugar/Realization/Custom/CustomProvider.cs b/Src/Asp.Net/SqlSugar/Realization/Custom/CustomProvider.cs new file mode 100644 index 000000000..08a0aadc7 --- /dev/null +++ b/Src/Asp.Net/SqlSugar/Realization/Custom/CustomProvider.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SqlSugar +{ + public class CustomProvider + { + internal static ISugarQueryable GetQueryable(string dbName, string dllName) + { + throw new NotImplementedException(); + } + } +} diff --git a/Src/Asp.Net/SqlSugar/SqlSugar.csproj b/Src/Asp.Net/SqlSugar/SqlSugar.csproj index 8786263da..4cac9d910 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugar.csproj +++ b/Src/Asp.Net/SqlSugar/SqlSugar.csproj @@ -102,6 +102,7 @@ +