Browse Source

Support OceanBaseForOracle

pull/40/head
sunkaixuan 1 year ago
parent
commit
fec28f56fc
  1. 157
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/DataTableExtensions/OceanBaseForOracleDataAdapter.cs
  2. BIN
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/NuGet.exe
  3. 51
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/CodeFirst/OceanBaseForOracleCodeFirst.cs
  4. 139
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/DbBind/OceanBaseForOracleDbBind.cs
  5. 12
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/DbFirst/OceanBaseForOracleDbFirst.cs
  6. 582
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/DbMaintenance/OceanBaseForOracleDbMaintenance.cs
  7. 345
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/OceanBaseForOracleProvider.cs
  8. 65
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/Queryable/OceanBaseForOracleQueryable.cs
  9. 154
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleBlukCopy.cs
  10. 81
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleBuilder.cs
  11. 13
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleDeleteBuilder.cs
  12. 386
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleExpressionContext.cs
  13. 88
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleFastBuilder.cs
  14. 217
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleInsertBuilder.cs
  15. 136
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleQueryBuilder.cs
  16. 150
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/SqlBuilder/OceanBaseForOracleUpdateBuilder.cs
  17. 17
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/SqlSugar.OceanBaseForOracle.csproj
  18. 24
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/SqlSugar.OdbcCore.nuspec
  19. 64
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/Tools/ErrorMessage.cs
  20. 20
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/Tools/ExpressionConst.cs
  21. 70
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/Tools/FileHelper.cs
  22. 73
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/Tools/UtilConstants.cs
  23. 158
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/Tools/UtilExtensions.cs
  24. 507
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/Tools/UtilMethods.cs
  25. 172
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/Tools/ValidateExtensions.cs
  26. 1
      Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/nuget.bat
  27. 4
      Src/Asp.NetCore2/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs
  28. 1
      Src/Asp.NetCore2/SqlSugar/Enum/DbType.cs
  29. 17
      Src/Asp.NetCore2/SqlSugarCore.sln

157
Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/DataTableExtensions/OceanBaseForOracleDataAdapter.cs

@ -0,0 +1,157 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Odbc;
using System.Text;
namespace SqlSugar.OceanBaseForOracle
{
/// <summary>
/// 数据填充器
/// </summary>
public class OceanBaseForOracleDataAdapter : IDataAdapter
{
private OdbcCommand command;
private string sql;
private OdbcConnection _sqlConnection;
/// <summary>
/// SqlDataAdapter
/// </summary>
/// <param name="command"></param>
public OceanBaseForOracleDataAdapter(OdbcCommand command)
{
this.command = command;
}
public OceanBaseForOracleDataAdapter()
{
}
/// <summary>
/// SqlDataAdapter
/// </summary>
/// <param name="sql"></param>
/// <param name="_sqlConnection"></param>
public OceanBaseForOracleDataAdapter(string sql, OdbcConnection _sqlConnection)
{
this.sql = sql;
this._sqlConnection = _sqlConnection;
}
/// <summary>
/// SelectCommand
/// </summary>
public OdbcCommand SelectCommand
{
get
{
if (this.command == null)
{
var conn = (OdbcConnection)this._sqlConnection;
this.command = conn.CreateCommand();
this.command.CommandText = sql;
}
return this.command;
}
set
{
this.command = value;
}
}
/// <summary>
/// Fill
/// </summary>
/// <param name="dt"></param>
public void Fill(DataTable dt)
{
if (dt == null)
{
dt = new DataTable();
}
var columns = dt.Columns;
var rows = dt.Rows;
using (var dr = command.ExecuteReader())
{
for (int i = 0; i < dr.FieldCount; i++)
{
string name = dr.GetName(i).Trim();
if (!columns.Contains(name))
columns.Add(new DataColumn(name, dr.GetFieldType(i)));
else
{
columns.Add(new DataColumn(name + i, dr.GetFieldType(i)));
}
}
while (dr.Read())
{
DataRow daRow = dt.NewRow();
for (int i = 0; i < columns.Count; i++)
{
daRow[columns[i].ColumnName] = dr.GetValue(i);
}
dt.Rows.Add(daRow);
}
}
dt.AcceptChanges();
}
/// <summary>
/// Fill
/// </summary>
/// <param name="ds"></param>
public void Fill(DataSet ds)
{
if (ds == null)
{
ds = new DataSet();
}
using (var dr = command.ExecuteReader())
{
do
{
var dt = new DataTable();
var columns = dt.Columns;
var rows = dt.Rows;
for (int i = 0; i < dr.FieldCount; i++)
{
string name = dr.GetName(i).Trim();
if (dr.GetFieldType(i).Name == "DateTime")
{
if (!columns.Contains(name))
columns.Add(new DataColumn(name, UtilConstants.DateType));
else
{
columns.Add(new DataColumn(name + i, UtilConstants.DateType));
}
}
else
{
if (!columns.Contains(name))
columns.Add(new DataColumn(name, dr.GetFieldType(i)));
else
{
columns.Add(new DataColumn(name + i, dr.GetFieldType(i)));
}
}
}
while (dr.Read())
{
DataRow daRow = dt.NewRow();
for (int i = 0; i < columns.Count; i++)
{
daRow[columns[i].ColumnName] = dr.GetValue(i);
}
dt.Rows.Add(daRow);
}
dt.AcceptChanges();
ds.Tables.Add(dt);
} while (dr.NextResult());
}
}
}
}

BIN
Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/NuGet.exe

Binary file not shown.

51
Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/CodeFirst/OceanBaseForOracleCodeFirst.cs

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar.OceanBaseForOracle
{
public class OceanBaseForOracleCodeFirst : CodeFirstProvider
{
public OceanBaseForOracleCodeFirst()
{
if (DefultLength == 0)
DefultLength = 40;
}
protected override int DefultLength { get; set; }
protected override void GetDbType(EntityColumnInfo item, Type propertyType, DbColumnInfo result)
{
if (!string.IsNullOrEmpty(item.DataType))
{
result.DataType = item.DataType;
}
else if (propertyType.IsEnum())
{
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(item.Length > 9 ? UtilConstants.LongType.Name : UtilConstants.IntType.Name);
}
else
{
if (propertyType.Name.Equals("Guid", StringComparison.CurrentCultureIgnoreCase))
{
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(UtilConstants.StringType.Name);
if (result.Length <= 1)
{
result.Length = 36;
}
}
else
{
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(propertyType.Name);
}
}
}
protected override void KeyAction(EntityColumnInfo item, DbColumnInfo dbColumn, out bool pkDiff, out bool idEntityDiff)
{
pkDiff = item.IsPrimarykey != dbColumn.IsPrimarykey;
idEntityDiff = false;
}
}
}

139
Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/DbBind/OceanBaseForOracleDbBind.cs

@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar.OceanBaseForOracle
{
public class OceanBaseForOracleDbBind : DbBindProvider
{
public override string GetDbTypeName(string csharpTypeName)
{
if (csharpTypeName == UtilConstants.ByteArrayType.Name)
return "blob";
if (csharpTypeName.ToLower() == "int32")
csharpTypeName = "int";
if (csharpTypeName.ToLower() == "int16")
csharpTypeName = "short";
if (csharpTypeName.ToLower() == "int64")
csharpTypeName = "long";
if (csharpTypeName.ToLower().IsIn("boolean", "bool"))
csharpTypeName = "bool";
if (csharpTypeName == "Guid")
csharpTypeName = "string";
if (csharpTypeName == "DateTimeOffset")
csharpTypeName = "DateTime";
var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase));
return mappings.HasValue() ? mappings.First().Key : "varchar";
}
public override string GetPropertyTypeName(string dbTypeName)
{
dbTypeName = dbTypeName.ToLower();
var propertyTypes = MappingTypes.Where(it => it.Value.ToString().ToLower() == dbTypeName || it.Key.ToLower() == dbTypeName);
if (dbTypeName == "int32")
{
return "int";
}
else if (dbTypeName == "int64")
{
return "long";
}
else if (dbTypeName == "int16")
{
return "short";
}
else if (propertyTypes == null)
{
return "other";
}
else if (dbTypeName == "xml" || dbTypeName == "string")
{
return "string";
}
if (dbTypeName == "byte[]")
{
return "byte[]";
}
else if (propertyTypes == null || propertyTypes.Count() == 0)
{
Check.ThrowNotSupportedException(string.Format(" \"{0}\" Type NotSupported, DbBindProvider.GetPropertyTypeName error.", dbTypeName));
return null;
}
else if (propertyTypes.First().Value == CSharpDataType.byteArray)
{
return "byte[]";
}
else
{
return propertyTypes.First().Value.ToString();
}
}
public override List<KeyValuePair<string, CSharpDataType>> MappingTypes
{
get
{
var extService = this.Context.CurrentConnectionConfig.ConfigureExternalServices;
if (extService != null && extService.AppendDataReaderTypeMappings.HasValue())
{
return extService.AppendDataReaderTypeMappings.Union(MappingTypesConst).ToList();
}
else
{
return MappingTypesConst;
}
}
}
public static List<KeyValuePair<string, CSharpDataType>> MappingTypesConst = new List<KeyValuePair<string, CSharpDataType>>()
{
new KeyValuePair<string, CSharpDataType>("int",CSharpDataType.@int),
new KeyValuePair<string, CSharpDataType>("integer",CSharpDataType.@int),
new KeyValuePair<string, CSharpDataType>("interval year to month",CSharpDataType.@int),
new KeyValuePair<string, CSharpDataType>("interval day to second",CSharpDataType.@int),
new KeyValuePair<string, CSharpDataType>("number",CSharpDataType.@int),
new KeyValuePair<string, CSharpDataType>("number",CSharpDataType.@float),
new KeyValuePair<string, CSharpDataType>("number",CSharpDataType.@short),
new KeyValuePair<string, CSharpDataType>("number",CSharpDataType.@byte),
new KeyValuePair<string, CSharpDataType>("number",CSharpDataType.@double),
new KeyValuePair<string, CSharpDataType>("number",CSharpDataType.@long),
new KeyValuePair<string, CSharpDataType>("number",CSharpDataType.@bool),
new KeyValuePair<string, CSharpDataType>("number",CSharpDataType.@decimal),
new KeyValuePair<string, CSharpDataType>("number",CSharpDataType.Single),
new KeyValuePair<string, CSharpDataType>("decimal",CSharpDataType.@decimal),
new KeyValuePair<string, CSharpDataType>("decimal",CSharpDataType.Single),
new KeyValuePair<string, CSharpDataType>("varchar",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("varchar2",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("nvarchar2",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("xmltype",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("char",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("nchar",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("clob",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("long",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("nclob",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("rowid",CSharpDataType.@string),
new KeyValuePair<string, CSharpDataType>("date",CSharpDataType.DateTime),
new KeyValuePair<string, CSharpDataType>("timestamptz",CSharpDataType.DateTime),
new KeyValuePair<string, CSharpDataType>("timestamp",CSharpDataType.DateTime),
new KeyValuePair<string, CSharpDataType>("timestamp with local time zone",CSharpDataType.DateTime),
new KeyValuePair<string, CSharpDataType>("timestamp with time zone",CSharpDataType.DateTime),
new KeyValuePair<string, CSharpDataType>("float",CSharpDataType.@decimal),
new KeyValuePair<string, CSharpDataType>("blob",CSharpDataType.byteArray),
new KeyValuePair<string, CSharpDataType>("long raw",CSharpDataType.byteArray),
new KeyValuePair<string, CSharpDataType>("longraw",CSharpDataType.byteArray),
new KeyValuePair<string, CSharpDataType>("raw",CSharpDataType.byteArray),