diff --git a/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/4TDSQLForOracleODBCTest.csproj b/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/4TDSQLForOracleODBCTest.csproj
new file mode 100644
index 0000000000000000000000000000000000000000..1907a8f65fa1933b8f046765131511315ab2faa1
--- /dev/null
+++ b/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/4TDSQLForOracleODBCTest.csproj
@@ -0,0 +1,16 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/Config.cs b/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/Config.cs
new file mode 100644
index 0000000000000000000000000000000000000000..9f301dbbb2a312cb9e788070fa03b84edef1a86e
--- /dev/null
+++ b/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/Config.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TDSQLForOracleODBCTest
+{
+ ///
+ /// Setting up the database name does not require you to create the database
+ /// 设置好数据库名不需要你去手动建库
+ ///
+ public class Config
+ {
+ ///
+ /// Account have permission to create database
+ /// 用有建库权限的数据库账号
+ ///
+ public static string ConnectionString = "Driver={TDSQL PostgreSQL Unicode(x64)};Server=172.19.4.37;Port=11001;Database=XIRBOC;Uid=XRFQ_APP;Pwd=xQuant.2026;ConnSettings=set search_path to XRFQ_APP;";
+ ///
+ /// Account have permission to create database
+ /// 用有建库权限的数据库账号
+ ///
+ public static string ConnectionString2 = "Driver={GBase ODBC DRIVER (64-Bit)};Host=localhost;Service=19088;Server=gbase01;Database=testdb;Protocol=onsoctcp;Uid=gbasedbt;Pwd=GBase123;Db_locale=zh_CN.utf8;Client_locale=zh_CN.utf8";
+ ///
+ /// Account have permission to create database
+ /// 用有建库权限的数据库账号
+ ///
+ public static string ConnectionString3 = "Driver={GBase ODBC DRIVER (64-Bit)};Host=localhost;Service=19088;Server=gbase01;Database=testdb;Protocol=onsoctcp;Uid=gbasedbt;Pwd=GBase123;Db_locale=zh_CN.utf8;Client_locale=zh_CN.utf8";
+ }
+}
diff --git a/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/Program.cs b/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/Program.cs
new file mode 100644
index 0000000000000000000000000000000000000000..0ee48f17ddaab4fa5a1a701213458a3c15101c10
--- /dev/null
+++ b/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/Program.cs
@@ -0,0 +1,171 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using xTPLM.RFQ.Model.XRFQ_APP;
+
+namespace TDSQLForOracleODBCTest
+{
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### MasterSlave Start ####");
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = Config.ConnectionString,//Master Connection
+ DbType = DbType.TDSQLForOracleODBC,//Oracle 模式用这个 ,如果是MySql 模式用DbType.MySql
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ });
+ //var date = DateTime.Now;
+ ////查询
+ //var list = db.Queryable().Where(m => m.ORDER_DATE.Value.Date <= date.Date).ToList();
+
+
+ //var list2 = db.Queryable().Where(m => m.ORDER_DATE.Value.Date <= date.Date).ToOffsetPage(1, 50);
+ //var item = new TRFQ_QUOTATION()
+ //{
+ // ORDER_DATE = DateTime.Now,
+ // Q_STATUS = 0,
+ //};
+
+ //var item2 = new TRFQ_QUOTATION()
+ //{
+ // ORDER_DATE = DateTime.Now,
+ // Q_STATUS = 0,
+ //};
+
+ //var item3 = new TRFQ_QUOTATION()
+ //{
+ // ORDER_DATE = DateTime.Now,
+ // Q_STATUS = 0,
+ //};
+ //var insertList = new List() { item, item2, item3 };
+ ////新增
+ //var newid = db.Insertable(insertList).ExecuteReturnIdentity();
+ //item.Q_SYSID = newid;
+
+ ////修改
+ //db.Updateable().SetColumns(it => new TRFQ_QUOTATION()
+ //{
+ // Q_STATUS = 1
+ //}).Where(m => m.Q_SYSID == newid).ExecuteCommand();
+
+ //item.Q_STATUS = 2;
+ ////修改
+ //db.Updateable(item).UpdateColumns(["Q_STATUS"]).ExecuteCommand();
+
+ //item.Q_STATUS = 3;
+ //List updateList = [item];
+ //updateList.Add(new TRFQ_QUOTATION
+ //{
+ // Q_SYSID = 15739,
+ // Q_STATUS = 4
+ //});
+
+ List updateList = [];
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 85583,
+ PARTYNAME = "北京证券公司",
+ PARTYNAME_SHORT = "北京证券公司",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 106742,
+ PARTYNAME = "财通基金丰悦稳健6号单一资产管理计划",
+ PARTYNAME_SHORT = "财通基金丰悦稳健6号单一",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 132460,
+ PARTYNAME = "汇添富全天候策略1号集合资产管理计划",
+ PARTYNAME_SHORT = "汇添富全天候策略1号集合",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ updateList.Add(new TRFQ_COUNTERPARTY
+ {
+ P_SYSID = 83442,
+ PARTYNAME = "中国银行股份有限公司",
+ PARTYNAME_SHORT = "中国银行",
+ });
+ //修改
+ db.Updateable(updateList).UpdateColumns(["PARTYNAME", "PARTYNAME_SHORT"]).ExecuteCommand();
+ }
+ }
+}
diff --git a/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/TRFQ_COUNTERPARTY.cs b/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/TRFQ_COUNTERPARTY.cs
new file mode 100644
index 0000000000000000000000000000000000000000..a7cef1ffc9875dc1f06474af32041c455a786dba
--- /dev/null
+++ b/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/TRFQ_COUNTERPARTY.cs
@@ -0,0 +1,315 @@
+using System;
+using System.Collections.Generic;
+using SqlSugar;
+
+namespace xTPLM.RFQ.Model.XRFQ_APP
+{
+ ///
+ ///交易对手表
+ ///
+ [SugarTable("TRFQ_COUNTERPARTY")]
+ public partial class TRFQ_COUNTERPARTY
+ {
+ public TRFQ_COUNTERPARTY()
+ {
+
+
+ }
+ ///
+ /// Desc:主键
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsNullable = false, IsPrimaryKey = true, OracleSequenceName = "TRFQ_COUNTERPARTY$SEQ", IsIdentity = true)]
+ public int P_SYSID { get; set; }
+
+ ///
+ /// Desc:名称
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsNullable = false, Length = 1000)]
+ public string PARTYNAME { get; set; }
+
+ ///
+ /// Desc:简称
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 200)]
+ public string PARTYNAME_SHORT { get; set; }
+
+ ///
+ /// Desc:启用状态:0=停用;1=启用
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? PARTYSTATUS { get; set; }
+
+ ///
+ /// 是否启用
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public bool IsOpen
+ {
+ get
+ {
+ return this.PARTYSTATUS == 1;
+ }
+ set
+ {
+ this.PARTYSTATUS = value ? 1 : 0;
+ }
+ }
+
+ ///
+ /// Desc:银行间会员代码
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 50)]
+ public string CNBD_MEMBERID { get; set; }
+
+ ///
+ /// Desc:外汇21位机构代码
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 50)]
+ public string CNBD_ORGCODE { get; set; }
+
+ ///
+ /// Desc:所在地域
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 50)]
+ public string BELONGTOAREA { get; set; }
+
+ ///
+ /// Desc:上交所固收平台交易商代码
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 32)]
+ public string SHG_FIX_CUSTCODE { get; set; }
+
+ ///
+ /// Desc:新增类型:0:手动,1:自动
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 10)]
+ public string PARTYSOURCE { get; set; }
+
+ ///
+ /// Desc:统一社会信用代码
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 100)]
+ public string CREDITCODE { get; set; }
+
+ ///
+ /// Desc:法人代表
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 200)]
+ public string LEGALPERSON { get; set; }
+
+ ///
+ /// Desc:营业执照有效日期
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 10)]
+ public string EXPDATE { get; set; }
+
+ ///
+ /// Desc:备注
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 500)]
+ public string REMARK { get; set; }
+
+ ///
+ /// Desc:外汇做市商类型:0 非做市商,1 做市商,2 尝试做市商-综合做市,3 尝试做市商-专项做市
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 10)]
+ public string MARKETMAKER_TYPE { get; set; }
+
+ ///
+ /// Desc:最后更新人
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 32)]
+ public string UPDATED_BY { get; set; }
+
+ ///
+ /// Desc:最后更新时间
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? UPDATED_TIME { get; set; }
+
+ ///
+ /// Desc:别名
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 1000)]
+ public string ALIAS { get; set; }
+
+ ///
+ /// Desc:外部ID
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? P_EXTID { get; set; }
+
+ ///
+ /// Desc:导入时间
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? IMPORTTIME { get; set; }
+
+ ///
+ /// Desc:所属机构
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? PARENTORGANPARTYID { get; set; }
+
+ ///
+ /// Desc:客户信评等级
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 50)]
+ public string CREDITLEVEL { get; set; }
+
+ ///
+ /// 净资产
+ ///
+ [SugarColumn(IsNullable = true)]
+ public decimal? PARTY_NET_ASSETS { get; set; }
+
+ ///
+ /// 交易对手名称_拼音首拼
+ ///
+ [SugarColumn(IsNullable = true, Length = 512)]
+ public string PARTYNAME_PINYIN { get; set; }
+
+ ///
+ /// 交易对手简称_拼音首拼
+ ///
+ [SugarColumn(IsNullable = true, Length = 512)]
+ public string PARTYNAME_SHORT_PINYIN { get; set; }
+
+ ///
+ /// 是否法人:1,法人;0,非法人
+ ///
+ [SugarColumn(IsNullable = true, Length = 1)]
+ public string ISLEGALPERSON { get; set; }
+
+ ///
+ /// 募集方式
+ ///
+ [SugarColumn(IsNullable = true, Length = 128)]
+ public string RAISEWAY { get; set; }
+
+ #region 数据库忽略字段
+
+ ///
+ /// 对手类型描述
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string PARTY_TYPE_DESC
+ {
+ get
+ {
+ if (ISLEGALPERSON == "0")
+ {
+ return "非法人户";
+ }
+ else if (ISLEGALPERSON == "1")
+ {
+ return "法人户";
+ }
+
+ return string.Empty;
+ }
+ }
+
+ ///
+ /// 所属机构名称
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string PARENTORGANPARTY { get; set; }
+
+ ///
+ /// 更新人名称
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string UPDATED_BY_NAME { get; set; }
+
+ ///
+ /// 是否满足入库标准
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public int? IS_CHECK_SUCCESS { get; set; }
+
+ ///
+ /// 是否符合入库标准(尽调表需求)
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public bool? IS_STANDARD
+ {
+ get
+ {
+ if (this.IS_CHECK_SUCCESS.HasValue)
+ {
+ return this.IS_CHECK_SUCCESS == 1;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ ///
+ /// 尽调表到期日
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public DateTime? END_DATE { get; set; }
+
+ ///
+ /// 尽调表是否到期
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public bool IsEnd
+ {
+ get
+ {
+ if (END_DATE.HasValue)
+ {
+ return END_DATE.Value.Date < DateTime.Now.Date;
+ }
+ return false;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/TRFQ_QUOTATION.cs b/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/TRFQ_QUOTATION.cs
new file mode 100644
index 0000000000000000000000000000000000000000..9f7c80f0c0a1d0da6ad9c7a330caf571f7712060
--- /dev/null
+++ b/Src/Asp.NetCore2/4TDSQLForOracleODBCTest/TRFQ_QUOTATION.cs
@@ -0,0 +1,654 @@
+using Newtonsoft.Json;
+using SqlSugar;
+
+namespace xTPLM.RFQ.Model.XRFQ_APP
+{
+ ///
+ ///询价记录表
+ ///
+ [SugarTable("TRFQ_QUOTATION")]
+ public partial class TRFQ_QUOTATION
+ {
+ ///
+ /// 询价序列名称
+ ///
+ public const string SequenceName = "TRFQ_QUOTATION$SEQ";
+ public TRFQ_QUOTATION()
+ {
+
+
+ }
+ ///
+ /// Desc:主键序号自增序列
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsNullable = false, IsPrimaryKey = true, OracleSequenceName = SequenceName, IsIdentity = true)]
+ public int Q_SYSID { get; set; }
+
+ ///
+ /// Desc:QQ号(由于对接QTrade,所以当CONTACTNUMBER_TYPE=2时,此字段存储QT号)
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 50)]
+ public string QQ_NUMBER { get; set; }
+
+ ///
+ /// Desc:本方交易员
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 100)]
+ public string SELF_TRADER { get; set; }
+
+ ///
+ /// Desc:执行市场
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 50)]
+ public string EXE_MARKET { get; set; }
+
+ ///
+ /// Desc:金融工具Code
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 100)]
+ public string I_CODE { get; set; }
+
+ ///
+ /// Desc:金融工具A_TYPE
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 100)]
+ public string A_TYPE { get; set; }
+
+ ///
+ /// Desc:金融工具M_TYPE
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 100)]
+ public string M_TYPE { get; set; }
+
+ ///
+ /// Desc:面额(万)
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public decimal? ORDER_MONEY { get; set; }
+
+ ///
+ /// 实际面额
+ /// 基于剩余本金计算
+ ///
+ [SugarColumn(IsNullable = true)]
+ public decimal? ACTUAL_AMOUNT { get; set; }
+
+ ///
+ /// Desc:到期收益率
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public decimal? BND_YTM { get; set; }
+
+ ///
+ /// Desc:行权收益率
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public decimal? BND_YTM_OE { get; set; }
+
+ ///
+ /// Desc:净价
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public decimal? BND_NETPRICE { get; set; }
+
+ ///
+ /// Desc:全价
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public decimal? BND_PRICE { get; set; }
+
+ ///
+ /// Desc:交易方向
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 50)]
+ public int? TRADER_TYPE { get; set; }
+
+ ///
+ /// Desc:交易日期
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? ORDER_DATE { get; set; }
+
+ ///
+ /// Desc:结算日期
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? SETDATE { get; set; }
+
+ ///
+ /// Desc:清算速度
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, ColumnDataType = "INT")]
+ public int? SET_DAYS { get; set; }
+
+ ///
+ /// Desc:交易对手
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? PARTY_ID { get; set; }
+
+ ///
+ /// Desc:实际交易对手
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? PARTYID_ACTUAL { get; set; }
+
+ ///
+ /// Desc:对方交易员
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? TRADER_CP { get; set; }
+
+ ///
+ /// Desc:报价发起方
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 1)]
+ public int? QUOTE_SPONSOR { get; set; }
+
+ ///
+ /// Desc:预期报价方式
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, ColumnName = "DEAL_TYPE", ColumnDataType = "INT")]
+ public int? DEAL_TYPE { get; set; }
+
+ ///
+ /// Desc:中介机构
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 50)]
+ public string INTERMEDIATION { get; set; }
+
+ ///
+ /// Desc:上交所固收平台约定号
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 20)]
+ public string SHG_AGREENUM { get; set; }
+
+ ///
+ /// Desc:上交所固收平台对手方交易员代码
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 50)]
+ public string SHG_TRADER_CP { get; set; }
+
+ ///
+ /// Desc:上交所固收平台对手方席位号
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 50)]
+ public string SHG_SEATNO_CP { get; set; }
+
+ ///
+ /// Desc:导入时间
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? IMPORT_TIME { get; set; }
+
+ ///
+ /// Desc:交易备注
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 1000)]
+ public string REMARK { get; set; }
+
+ ///
+ /// Desc:交易是否删除:0未删除 1删除
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int IS_DELETE { get; set; } = 0;
+
+ ///
+ /// Desc:询价状态
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName = "Q_STATUS", ColumnDataType = "INT")]
+ public int? Q_STATUS { get; set; }
+
+
+ ///
+ /// Desc:反向报价(和本表的主键关联)
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? SYSID_INVERSE { get; set; }
+
+ ///
+ /// Desc:交易系统交易
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? SYSID_EXT { get; set; }
+
+ ///
+ /// Desc:公开级别,0:个人,1:小组,2:公共
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? Q_PUBLICLEVEL { get; set; }
+
+ ///
+ /// Desc:报价来源,
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, ColumnDataType = "INT")]
+ public int? Q_BID_SOURCE { get; set; }
+
+ ///
+ /// Desc:外部交易标识
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 128)]
+ public string EXT_TRADE_ID { get; set; }
+
+ ///
+ /// Desc:最后一次修改时间
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? UPDATE_TIME { get; set; }
+
+ ///
+ /// Desc:最后一次修改人
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 32)]
+ public string UPDATE_BY { get; set; }
+
+ ///
+ /// Desc:外部联系账号类型:1-QQ号,2-QT号
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? CONTACTNUMBER_TYPE { get; set; }
+
+ ///
+ /// Desc:价格类型: 1-到期收益率 2-行权收益率 3-净价 4-全价
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, ColumnDataType = "INT")]
+ public int? PRICE_TYPE { get; set; }
+
+ ///
+ /// Desc:下达状态 0:未下达,5:下达中,10:下达成功,-1:下达失败
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsNullable = false, ColumnName = "RELEASE_STATUS")]
+ public int RELEASE_STATUS { get; set; }
+
+ ///
+ /// Desc:下达信息
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 1024)]
+ public string RELEASE_MESSAGE { get; set; }
+
+ ///
+ /// Desc:下达时间
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? RELEASE_TIME { get; set; }
+
+ ///
+ /// Desc:内政账户
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 64)]
+ public string SECU_ACCID { get; set; }
+
+ ///
+ /// Desc:本方操作员
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 64)]
+ public int? SELF_OPERATOR { get; set; }
+
+ ///
+ /// Desc:交易执行员
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 64)]
+ public string EXECUTOR { get; set; }
+
+ ///
+ /// Desc:xIR交易组合ID
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 64)]
+ public string GRPID { get; set; }
+
+ ///
+ /// Desc:xIR交易组合名称
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 512)]
+ public string GRPNAME { get; set; }
+
+ ///
+ /// Desc:xIR交易子组合ID
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 64)]
+ public string CHILDGROUPID { get; set; }
+
+ ///
+ /// Desc:xIR交易子组合名称
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 512)]
+ public string CHILDGROUPNAME { get; set; }
+
+ ///
+ /// Desc:自定义组合类型
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 64)]
+ public string GRPTYPE_CUSTOM { get; set; }
+
+ ///
+ /// Desc:自定义子组合类型
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 64)]
+ public string CHILDGRPTYPE_CUSTOM { get; set; }
+
+ ///
+ /// Desc:临时交易对手
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 128)]
+ public string PARTYNAMETEMPORITY { get; set; }
+
+ ///
+ /// Desc:创建时间
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? CREATE_TIME { get; set; }
+
+ ///
+ /// Desc:中介费用
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true)]
+ public decimal? INTERMEDIARY_FEE { get; set; }
+
+ ///
+ /// Desc:报价执行员
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(IsNullable = true, Length = 128)]
+ public string EXECUTETRADER { get; set; }
+
+ ///
+ /// XIR交易系统状态
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? TRADESYSTEM_STATUS { get; set; }
+
+ ///
+ /// 对手方交易商代码
+ ///
+ [SugarColumn(IsNullable = true, Length = 256)]
+ public string DEALER_CODE { get; set; }
+
+ ///
+ /// 对手方交易主体代码
+ ///
+ [SugarColumn(IsNullable = true, Length = 256)]
+ public string TRADEBODY_CODE { get; set; }
+
+ ///
+ /// 拆分前询价ID(用于记录该询价是否是拆分询价,并记录拆分前的询价ID)
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? ORI_QID { get; set; }
+
+ ///
+ /// 首期结算状态 #该字段目前没有落地,当作数据库忽略字段使用
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? FST_STATE { get; set; }
+
+ ///
+ /// 到期结算状态 #该字段目前没有落地,当作数据库忽略字段使用
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? END_STATE { get; set; }
+
+ ///
+ /// 应计利息
+ ///
+ [SugarColumn(IsNullable = true)]
+ public decimal? AIAMOUNT { get; set; }
+
+ ///
+ /// 结算金额
+ ///
+ [SugarColumn(IsNullable = true)]
+ public decimal? ORDAMOUNT { get; set; }
+
+ ///
+ /// 外部成交编号
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string EXTORDID { get; set; }
+
+ ///
+ /// 原始文本
+ ///
+ [SugarColumn(IsNullable = true, Length = 2000)]
+ public string ORIGNAL_TEXT { get; set; }
+
+ ///
+ /// 实际交易对手信息
+ ///
+ [SugarColumn(IsNullable = true, Length = 200)]
+ public string ACTUALPARTY_LINKMAN { get; set; }
+
+ ///
+ /// 本方交易商
+ ///
+ [SugarColumn(IsNullable = true, Length = 512)]
+ public string SELF_DEALER { get; set; }
+
+ ///
+ /// 本方交易主体
+ ///
+ [SugarColumn(IsNullable = true, Length = 512)]
+ public string SELF_INVESTOR { get; set; }
+
+ ///
+ /// 对手方主体类型
+ ///
+ [SugarColumn(IsNullable = true, Length = 512)]
+ public string CP_INVESTOR_TYPE { get; set; }
+
+ ///
+ /// 投资经理
+ ///
+ [SugarColumn(IsNullable = true, Length = 1024)]
+ public int? INVESTMENT_MANAGER { get; set; }
+
+ ///
+ /// 询价备注
+ ///
+ [SugarColumn(IsNullable = true, Length = 4000)]
+ public string QUOTA_REMARK { get; set; }
+
+ ///
+ /// 是否内部询价(交易) 1:是
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? IS_INTERNAL { get; set; }
+
+ ///
+ /// 对手方内部证券账户
+ ///
+ [SugarColumn(IsNullable = true, Length = 256)]
+ public string SECU_INT_CP { get; set; }
+
+ ///
+ /// 内部对手交易员
+ ///
+ [SugarColumn(IsNullable = true, Length = 512)]
+ public string SECU_TRADER_CP { get; set; }
+
+ ///
+ /// 数据来源 系统简称(接口导入时,存储导入的系统标识)
+ ///
+ public string SOURCE_TYPE { get; set; }
+
+ ///
+ /// 预计收益率
+ ///
+ public decimal? EXPECTED_YIELD { get; set; }
+
+ ///
+ /// 单张应计利息
+ ///
+ public decimal? UNIT_AIAMOUNT { get; set; }
+
+ ///
+ /// 报价途径
+ ///
+ [SugarColumn(IsNullable = true, Length = 64)]
+ public string QUOTECHANNEL { get; set; }
+
+ ///
+ /// 当前审批角色
+ ///
+ public string APPROVALUSER { get; set; }
+
+ #region 资管字段
+ ///
+ /// 产品ID(内资代码)
+ ///
+ [SugarColumn(IsNullable = true, Length = 128)]
+ public string CASH_ACCID { get; set; }
+
+
+ #region 数据库忽略字段
+
+ ///
+ /// 产品名称
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string PRODUCT_NAME { get; set; }
+
+ #endregion
+
+ #endregion
+
+ ///
+ /// 将询价价格设置为有效价格
+ ///
+ public void QuotaPriceAuth()
+ {
+ //收益率不能小于0,不能大于10000
+ if (this.BND_YTM >= 10000 || this.BND_YTM < 0)
+ {
+ this.BND_YTM = 0;
+ }
+
+ //收益率不能小于0,不能大于10000
+ if (this.BND_YTM_OE >= 10000 || this.BND_YTM_OE < 0)
+ {
+ this.BND_YTM_OE = 0;
+ }
+
+ //全价不能小于0
+ if (this.BND_PRICE < 0)
+ {
+ this.BND_PRICE = 0;
+ }
+
+ //净价不能小于0
+ if (this.BND_NETPRICE < 0)
+ {
+ this.BND_NETPRICE = 0;
+ }
+ }
+
+
+
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/DbBind/OceanBaseForOracleDbBind.cs b/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/DbBind/OceanBaseForOracleDbBind.cs
index c886c81f274a9de2c77b09350f16e0bb7dad27e0..d72715e5aca95ca772fd75fa3da16659aa6f29c4 100644
--- a/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/DbBind/OceanBaseForOracleDbBind.cs
+++ b/Src/Asp.NetCore2/SqlSugar.OceanBaseForOracle/OceanBase/DbBind/OceanBaseForOracleDbBind.cs
@@ -31,6 +31,10 @@ namespace SqlSugar.OceanBaseForOracle
{
dbTypeName = dbTypeName.ToLower();
var propertyTypes = MappingTypes.Where(it => it.Value.ToString().ToLower() == dbTypeName || it.Key.ToLower() == dbTypeName);
+ if (dbTypeName == "text")
+ {
+ return "other";
+ }
if (dbTypeName == "int32")
{
return "int";
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/DataTableExtensions/TDSQLForOracleDataAdapter.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/DataTableExtensions/TDSQLForOracleDataAdapter.cs
new file mode 100644
index 0000000000000000000000000000000000000000..9ffbe5d2ab5bcdef194f85adc0583f6fe8e3d564
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/DataTableExtensions/TDSQLForOracleDataAdapter.cs
@@ -0,0 +1,111 @@
+using System.Data;
+using System.Data.Odbc;
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ ///
+ /// 数据填充器
+ ///
+ public class TDSQLForOracleDataAdapter : IDataAdapter
+ {
+ private OdbcCommand command;
+ private string sql;
+ private OdbcConnection _sqlConnection;
+
+ ///
+ /// SqlDataAdapter
+ ///
+ ///
+ public TDSQLForOracleDataAdapter(OdbcCommand command)
+ {
+ this.command = command;
+ }
+
+ public TDSQLForOracleDataAdapter()
+ {
+
+ }
+
+ ///
+ /// SqlDataAdapter
+ ///
+ ///
+ ///
+ public TDSQLForOracleDataAdapter(string sql, OdbcConnection _sqlConnection)
+ {
+ this.sql = sql;
+ this._sqlConnection = _sqlConnection;
+ }
+
+ ///
+ /// SelectCommand
+ ///
+ 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;
+ }
+ }
+
+ ///
+ /// Fill
+ ///
+ ///
+ 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();
+ }
+
+ ///
+ /// Fill
+ ///
+ ///
+ public void Fill(DataSet ds)
+ {
+ using (var cmd = new OdbcDataAdapter(this.SelectCommand))
+ {
+ cmd.Fill(ds);
+ }
+ }
+ }
+
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/SqlSugar.TDSQLForOracleODBC.csproj b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/SqlSugar.TDSQLForOracleODBC.csproj
new file mode 100644
index 0000000000000000000000000000000000000000..550f4a6ed2f4157c34ab02800458891b0a471795
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/SqlSugar.TDSQLForOracleODBC.csproj
@@ -0,0 +1,26 @@
+
+
+
+ netstandard2.1
+ 5.33.4.216
+ sun_kai_xuan,guoshun.du
+ http://191.168.1.27:8080/back-end/xquant.sqlsugar
+
+
+ xQuant.SqlSugar.TDSQLForOracleODBC
+ 果糖大数据科技(南通)有限公司
+ 果糖大数据科技(南通)有限公司
+ 果糖大数据科技(南通)有限公司
+ True
+ True
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/CodeFirst/TDSQLForOracleODBCCodeFirst.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/CodeFirst/TDSQLForOracleODBCCodeFirst.cs
new file mode 100644
index 0000000000000000000000000000000000000000..2c2d3c61a1d954e83a8d85b2288b8ab39d1bb381
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/CodeFirst/TDSQLForOracleODBCCodeFirst.cs
@@ -0,0 +1,47 @@
+using System;
+
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public class TDSQLForOracleODBCCodeFirst : CodeFirstProvider
+ {
+ public TDSQLForOracleODBCCodeFirst()
+ {
+ 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;
+ }
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/DbBind/TDSQLForOracleODBCDbBind.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/DbBind/TDSQLForOracleODBCDbBind.cs
new file mode 100644
index 0000000000000000000000000000000000000000..fc348aa30211374edc3c67f09cafac4f61d5b863
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/DbBind/TDSQLForOracleODBCDbBind.cs
@@ -0,0 +1,197 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public class TDSQLForOracleODBCDbBind : DbBindProvider
+ {
+ public override string GetDbTypeName(string csharpTypeName)
+ {
+ csharpTypeName = GetValidCsharpTypeName(csharpTypeName);
+ if (csharpTypeName == UtilConstants.ByteArrayType.Name)
+ return "bytea";
+ 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 == "DateTimeOffset")
+ return "timestamptz";
+ var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase)).ToList();
+ if (mappings != null && mappings.Count > 0)
+ return mappings.First().Key;
+ else
+ return "varchar";
+ }
+
+ private string GetValidCsharpTypeName(string csharpTypeName)
+ {
+ if (csharpTypeName?.StartsWith("ora") == true && this.Context.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.Vastbase)
+ {
+ csharpTypeName = csharpTypeName.Replace("ora", "");
+ }
+ else if (csharpTypeName?.StartsWith("mssql_") == true && this.Context.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.Vastbase)
+ {
+ csharpTypeName = csharpTypeName.Replace("mssql_", "");
+ }
+ else if (csharpTypeName?.StartsWith("sys.") == true)
+ {
+ csharpTypeName = csharpTypeName.Replace("sys.", "");
+ }
+ return csharpTypeName;
+ }
+
+ public override string GetPropertyTypeName(string dbTypeName)
+ {
+ dbTypeName = dbTypeName.ToLower();
+ dbTypeName = GetValidCsharpTypeName(dbTypeName);
+ var propertyTypes = MappingTypes.Where(it => it.Value.ToString().ToLower() == dbTypeName || it.Key.ToLower() == dbTypeName);
+ if (dbTypeName == "text")
+ {
+ return "other";
+ }
+ if (propertyTypes == null || dbTypeName == "unknown")
+ {
+ return "other";
+ }
+ else if (dbTypeName == "xml" || dbTypeName == "string" || dbTypeName == "jsonb" || dbTypeName == "json")
+ {
+ return "string";
+ }
+ else if (dbTypeName == "bpchar")//数据库char datatype 查询出来的时候是 bpchar
+ {
+ return "char";
+ }
+ if (dbTypeName == "byte[]")
+ {
+ return "byte[]";
+ }
+ else if (propertyTypes == null || propertyTypes.Count() == 0)
+ {
+ if (dbTypeName.StartsWith("_"))
+ {
+ var dbTypeName2 = dbTypeName.TrimStart('_');
+ return MappingTypes.Where(it => it.Value.ToString().ToLower() == dbTypeName2 || it.Key.ToLower() == dbTypeName2).Select(it => it.Value + "[]").First();
+ }
+ else if (dbTypeName.EndsWith("geometry") || dbTypeName.EndsWith("geography"))
+ {
+ return CSharpDataType.@string.ToString();
+ }
+ 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> 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> MappingTypesConst = new List>(){
+
+ new KeyValuePair("int2",CSharpDataType.@short),
+ //new KeyValuePair("int1",CSharpDataType.@byte),
+ new KeyValuePair("smallint",CSharpDataType.@short),
+ new KeyValuePair("smallint",CSharpDataType.@byte),
+ new KeyValuePair("int4",CSharpDataType.@int),
+ new KeyValuePair("serial",CSharpDataType.@int),
+ new KeyValuePair("integer",CSharpDataType.@int),
+ new KeyValuePair("int8",CSharpDataType.@long),
+ new KeyValuePair("long",CSharpDataType.@long),
+ new KeyValuePair("bigint",CSharpDataType.@long),
+ new KeyValuePair("float4",CSharpDataType.@float),
+ new KeyValuePair("float4",CSharpDataType.Single),
+ new KeyValuePair("real",CSharpDataType.@float),
+ new KeyValuePair("float8",CSharpDataType.@double),
+ new KeyValuePair("double precision",CSharpDataType.@int),
+ new KeyValuePair("numeric",CSharpDataType.@decimal),
+ new KeyValuePair("decimal",CSharpDataType.@decimal),
+ new KeyValuePair("path",CSharpDataType.@decimal),
+ new KeyValuePair("point",CSharpDataType.@decimal),
+ new KeyValuePair("polygon",CSharpDataType.@decimal),
+
+ new KeyValuePair("boolean",CSharpDataType.@bool),
+ new KeyValuePair("bool",CSharpDataType.@bool),
+ new KeyValuePair("box",CSharpDataType.@bool),
+ new KeyValuePair("bytea",CSharpDataType.byteArray),
+
+ new KeyValuePair("varchar",CSharpDataType.@string),
+ new KeyValuePair("clob",CSharpDataType.@string),
+ new KeyValuePair("nvarchar2",CSharpDataType.@string),
+ new KeyValuePair("varchar2",CSharpDataType.@string),
+ new KeyValuePair("character varying",CSharpDataType.@string),
+ new KeyValuePair("geometry",CSharpDataType.@string),
+ new KeyValuePair("name",CSharpDataType.@string),
+ new KeyValuePair("text",CSharpDataType.@string),
+ new KeyValuePair("char",CSharpDataType.@string),
+ new KeyValuePair("character",CSharpDataType.@string),
+ new KeyValuePair("cidr",CSharpDataType.@string),
+ new KeyValuePair("circle",CSharpDataType.@string),
+ new KeyValuePair("tsquery",CSharpDataType.@string),
+ new KeyValuePair("tsvector",CSharpDataType.@string),
+ new KeyValuePair("txid_snapshot",CSharpDataType.@string),
+ new KeyValuePair("uuid",CSharpDataType.Guid),
+ new KeyValuePair("xml",CSharpDataType.@string),
+ new KeyValuePair("json",CSharpDataType.@string),
+
+ new KeyValuePair("interval",CSharpDataType.@decimal),
+ new KeyValuePair("lseg",CSharpDataType.@decimal),
+ new KeyValuePair("macaddr",CSharpDataType.@decimal),
+ new KeyValuePair("money",CSharpDataType.@decimal),
+ new KeyValuePair("timestamp",CSharpDataType.DateTime),
+ new KeyValuePair("timestamp with time zone",CSharpDataType.DateTime),
+ new KeyValuePair("timestamptz",CSharpDataType.DateTime),
+ new KeyValuePair("timestamp without time zone",CSharpDataType.DateTime),
+ new KeyValuePair("date",CSharpDataType.DateTime),
+ new KeyValuePair("time",CSharpDataType.DateTime),
+ new KeyValuePair("time with time zone",CSharpDataType.DateTime),
+ new KeyValuePair("timetz",CSharpDataType.DateTime),
+ new KeyValuePair("time without time zone",CSharpDataType.DateTime),
+
+ new KeyValuePair("bit",CSharpDataType.byteArray),
+ new KeyValuePair("bit varying",CSharpDataType.byteArray),
+ new KeyValuePair("varbit",CSharpDataType.@byte),
+ new KeyValuePair("time",CSharpDataType.TimeSpan),
+ new KeyValuePair("public.geometry",CSharpDataType.@object),
+ new KeyValuePair("public.geography",CSharpDataType.@object),
+ new KeyValuePair("inet",CSharpDataType.@object),
+
+ new KeyValuePair("number",CSharpDataType.@int),
+ new KeyValuePair("number",CSharpDataType.@float),
+ new KeyValuePair("number",CSharpDataType.@short),
+ new KeyValuePair("number",CSharpDataType.@byte),
+ new KeyValuePair("number",CSharpDataType.@double),
+ new KeyValuePair("number",CSharpDataType.@long),
+ new KeyValuePair("number",CSharpDataType.@bool),
+ new KeyValuePair("number",CSharpDataType.@decimal),
+ };
+ public override List StringThrow
+ {
+ get
+ {
+ return new List() { "int32", "datetime", "decimal", "double", "byte" };
+ }
+ }
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/DbFirst/TDSQLForOracleODBCDbFirst.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/DbFirst/TDSQLForOracleODBCDbFirst.cs
new file mode 100644
index 0000000000000000000000000000000000000000..2ab4fc5ebd509ba85937f8033eca7aefcdb4f884
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/DbFirst/TDSQLForOracleODBCDbFirst.cs
@@ -0,0 +1,6 @@
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public class TDSQLForOracleODBCDbFirst : DbFirstProvider
+ {
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/DbMaintenance/TDSQLForOracleODBCDbMaintenance.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/DbMaintenance/TDSQLForOracleODBCDbMaintenance.cs
new file mode 100644
index 0000000000000000000000000000000000000000..c45d7b7751571e22e33e4bda3a518b256b0862e3
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/DbMaintenance/TDSQLForOracleODBCDbMaintenance.cs
@@ -0,0 +1,659 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Common;
+using System.Linq;
+using System.Text.RegularExpressions;
+
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public class TDSQLForOracleODBCDbMaintenance : DbMaintenanceProvider
+ {
+ #region DML
+ protected override string GetDataBaseSql
+ {
+ get
+ {
+ return "SELECT datname FROM pg_database";
+ }
+ }
+ protected override string GetColumnInfosByTableNameSql
+ {
+ get
+ {
+ string schema = GetSchema();
+ string sql = @"select cast (pclass.oid as int4) as TableId,cast(ptables.tablename as varchar) as TableName,
+ pcolumn.column_name as DbColumnName,pcolumn.udt_name as DataType,
+ CASE WHEN pcolumn.numeric_scale >0 THEN pcolumn.numeric_precision ELSE pcolumn.character_maximum_length END as Length,
+ pcolumn.column_default as DefaultValue,
+ pcolumn.numeric_scale as DecimalDigits,
+ pcolumn.numeric_scale as Scale,
+ col_description(pclass.oid, pcolumn.ordinal_position) as ColumnDescription,
+ case when pkey.colname = pcolumn.column_name
+ then true else false end as IsPrimaryKey,
+ CASE
+ WHEN (current_setting('server_version_num')::INT >= 100000 AND pcolumn.is_identity = 'YES') THEN true
+ WHEN pcolumn.column_default LIKE 'nextval%' THEN true
+ ELSE false
+ END AS IsIdentity,
+ case when pcolumn.is_nullable = 'YES'
+ then true else false end as IsNullable
+ from (select * from pg_tables where upper(tablename) = upper('{0}') and schemaname='" + schema + @"') ptables inner join pg_class pclass
+ on ptables.tablename = pclass.relname inner join (SELECT *
+ FROM information_schema.columns where table_schema='" + schema + @"'
+ ) pcolumn on pcolumn.table_name = ptables.tablename and upper(pcolumn.table_name) = upper('{0}')
+ left join (
+ select pg_class.relname,pg_attribute.attname as colname from
+ pg_constraint inner join pg_class
+ on pg_constraint.conrelid = pg_class.oid
+ inner join pg_attribute on pg_attribute.attrelid = pg_class.oid
+ and pg_attribute.attnum = pg_constraint.conkey[1]
+ inner join pg_type on pg_type.oid = pg_attribute.atttypid
+ where pg_constraint.contype='p'
+ ) pkey on pcolumn.table_name = pkey.relname
+ order by table_catalog, table_schema, ordinal_position";
+ return sql;
+ }
+ }
+
+ protected override string GetTableInfoListSql
+ {
+ get
+ {
+ var schema = GetSchema();
+ return @"select cast(relname as varchar) as Name,
+ cast(obj_description(c.oid,'pg_class') as varchar) as Description from pg_class c
+ inner join
+ pg_namespace n on n.oid = c.relnamespace and nspname='" + schema + @"'
+ inner join
+ pg_tables z on z.tablename=c.relname
+ where relkind in('p', 'r') and relname not like 'pg\_%' and relname not like 'sql\_%' and schemaname='" + schema + "' order by relname";
+ }
+ }
+ protected override string GetViewInfoListSql
+ {
+ get
+ {
+ return @"select table_name as name from information_schema.views where table_schema ='" + GetSchema() + "' ";
+ }
+ }
+ #endregion
+
+ #region DDL
+ protected override string CreateDataBaseSql
+ {
+ get
+ {
+ return "CREATE DATABASE {0}";
+ }
+ }
+ protected override string AddPrimaryKeySql
+ {
+ get
+ {
+ return "ALTER TABLE {0} ADD PRIMARY KEY({2}) /*{1}*/";
+ }
+ }
+ protected override string AddColumnToTableSql
+ {
+ get
+ {
+ return "ALTER TABLE {0} ADD COLUMN {1} {2}{3} {4} {5} {6}";
+ }
+ }
+ protected override string AlterColumnToTableSql
+ {
+ get
+ {
+ return "alter table {0} ALTER COLUMN {1} {2}{3} {4} {5} {6}";
+ }
+ }
+ protected override string BackupDataBaseSql
+ {
+ get
+ {
+ return "mysqldump.exe {0} -uroot -p > {1} ";
+ }
+ }
+ protected override string CreateTableSql
+ {
+ get
+ {
+ return "CREATE TABLE {0}(\r\n{1} $PrimaryKey)";
+ }
+ }
+ protected override string CreateTableColumn
+ {
+ get
+ {
+ return "{0} {1}{2} {3} {4} {5}";
+ }
+ }
+ protected override string TruncateTableSql
+ {
+ get
+ {
+ return "TRUNCATE TABLE {0}";
+ }
+ }
+ protected override string BackupTableSql
+ {
+ get
+ {
+ return "create table {0} as (select * from {1} limit {2} offset 0)";
+ }
+ }
+ protected override string DropTableSql
+ {
+ get
+ {
+ return "DROP TABLE {0}";
+ }
+ }
+ protected override string DropColumnToTableSql
+ {
+ get
+ {
+ return "ALTER TABLE {0} DROP COLUMN {1}";
+ }
+ }
+ protected override string DropConstraintSql
+ {
+ get
+ {
+ return "ALTER TABLE {0} DROP CONSTRAINT {1}";
+ }
+ }
+ protected override string RenameColumnSql
+ {
+ get
+ {
+ return "ALTER TABLE {0} RENAME {1} TO {2}";
+ }
+ }
+ protected override string AddColumnRemarkSql => "comment on column {1}.{0} is '{2}'";
+
+ protected override string DeleteColumnRemarkSql => "comment on column {1}.{0} is ''";
+
+ protected override string IsAnyColumnRemarkSql { get { throw new NotSupportedException(); } }
+
+ protected override string AddTableRemarkSql => "comment on table {0} is '{1}'";
+
+ protected override string DeleteTableRemarkSql => "comment on table {0} is ''";
+
+ protected override string IsAnyTableRemarkSql { get { throw new NotSupportedException(); } }
+
+ protected override string RenameTableSql => "alter table {0} rename to {1}";
+
+ protected override string CreateIndexSql
+ {
+ get
+ {
+ return "CREATE {3} INDEX Index_{0}_{2} ON {0} ({1})";
+ }
+ }
+ protected override string AddDefaultValueSql
+ {
+ get
+ {
+ return "ALTER TABLE {0} ALTER COLUMN {1} SET DEFAULT {2}";
+ }
+ }
+ protected override string IsAnyIndexSql
+ {
+ get
+ {
+ return " SELECT count(1) WHERE upper('{0}') IN ( SELECT upper(indexname) FROM pg_indexes )";
+ }
+ }
+ protected override string IsAnyProcedureSql => throw new NotImplementedException();
+ #endregion
+
+ #region Check
+ protected override string CheckSystemTablePermissionsSql
+ {
+ get
+ {
+ return "select 1 from information_schema.columns limit 1 offset 0";
+ }
+ }
+ #endregion
+
+ #region Scattered
+ protected override string CreateTableNull
+ {
+ get
+ {
+ return "DEFAULT NULL";
+ }
+ }
+ protected override string CreateTableNotNull
+ {
+ get
+ {
+ return "NOT NULL";
+ }
+ }
+ protected override string CreateTablePirmaryKey
+ {
+ get
+ {
+ return "PRIMARY KEY";
+ }
+ }
+ protected override string CreateTableIdentity
+ {
+ get
+ {
+ return "serial";
+ }
+ }
+ #endregion
+
+ #region Methods
+ public override bool IsAnyTable(string tableName, bool isCache = true)
+ {
+ if (isCache == false)
+ {
+ var sql = $" SELECT 1 FROM pg_catalog.pg_tables \r\n WHERE schemaname = '" + GetSchema() + "' \r\n AND Lower(tablename) = '" + tableName.ToLower() + "' ";
+ return this.Context.Ado.GetInt(sql) > 0;
+ }
+ else
+ {
+ return base.IsAnyTable(tableName, isCache);
+ }
+ }
+ public override List GetDbTypes()
+ {
+ var result = this.Context.Ado.SqlQuery(@"SELECT DISTINCT data_type
+FROM information_schema.columns");
+ result.Add("varchar");
+ result.Add("timestamp");
+ result.Add("uuid");
+ result.Add("int2");
+ result.Add("int4");
+ result.Add("int8");
+ result.Add("time");
+ result.Add("date");
+ result.Add("float8");
+ result.Add("float4");
+ result.Add("json");
+ result.Add("jsonp");
+ return result.Distinct().ToList();
+ }
+ public override List GetTriggerNames(string tableName)
+ {
+ return this.Context.Ado.SqlQuery(@"SELECT tgname
+FROM pg_trigger
+WHERE tgrelid = '" + tableName + "'::regclass");
+ }
+ public override List GetFuncList()
+ {
+ return this.Context.Ado.SqlQuery(" SELECT routine_name\r\nFROM information_schema.routines\r\nWHERE lower( routine_schema ) = '" + GetSchema().ToLower() + "' AND routine_type = 'FUNCTION' ");
+ }
+ public override List GetIndexList(string tableName)
+ {
+ var sql = $"SELECT indexname, indexdef FROM pg_indexes WHERE upper(tablename) = upper('{tableName}') AND upper(schemaname) = upper('{GetSchema()}')";
+ return this.Context.Ado.SqlQuery(sql);
+ }
+ public override List GetProcList(string dbName)
+ {
+ var sql = $"SELECT proname FROM pg_proc p JOIN pg_namespace n ON p.pronamespace = n.oid WHERE n.nspname = '{dbName}'";
+ return this.Context.Ado.SqlQuery(sql);
+ }
+ public override bool AddDefaultValue(string tableName, string columnName, string defaultValue)
+ {
+ if (defaultValue?.StartsWith("'") == true && defaultValue?.EndsWith("'") == true && defaultValue?.Contains("(") == false
+ && !defaultValue.EqualCase("'current_timestamp'") && !defaultValue.EqualCase("'current_date'"))
+ {
+ string sql = string.Format(AddDefaultValueSql, this.SqlBuilder.GetTranslationColumnName(tableName), this.SqlBuilder.GetTranslationColumnName(columnName), defaultValue);
+ return this.Context.Ado.ExecuteCommand(sql) > 0;
+ }
+ else if (defaultValue.EqualCase("current_timestamp") || defaultValue.EqualCase("current_date"))
+ {
+ string sql = string.Format(AddDefaultValueSql, this.SqlBuilder.GetTranslationColumnName(tableName), this.SqlBuilder.GetTranslationColumnName(columnName), defaultValue);
+ return this.Context.Ado.ExecuteCommand(sql) > 0;
+ }
+ else if (defaultValue?.Contains("(") == false
+ && !defaultValue.EqualCase("'current_timestamp'") && !defaultValue.EqualCase("'current_date'"))
+ {
+ string sql = string.Format(AddDefaultValueSql, this.SqlBuilder.GetTranslationColumnName(tableName), this.SqlBuilder.GetTranslationColumnName(columnName), "'" + defaultValue + "'");
+ return this.Context.Ado.ExecuteCommand(sql) > 0;
+ }
+ else if (defaultValue?.ToLower()?.Contains("cast(") == true && defaultValue?.StartsWith("'") == true && defaultValue?.EndsWith("'") == true)
+ {
+ string sql = string.Format(AddDefaultValueSql, this.SqlBuilder.GetTranslationColumnName(tableName), this.SqlBuilder.GetTranslationColumnName(columnName), defaultValue.Replace("''", "'").TrimEnd('\'').TrimStart('\''));
+ return this.Context.Ado.ExecuteCommand(sql) > 0;
+ }
+ else if (defaultValue?.ToLower()?.Contains("now()") == true)
+ {
+ string sql = string.Format(AddDefaultValueSql, this.SqlBuilder.GetTranslationColumnName(tableName), this.SqlBuilder.GetTranslationColumnName(columnName), defaultValue.TrimEnd('\'').TrimStart('\''));
+ return this.Context.Ado.ExecuteCommand(sql) > 0;
+ }
+ else
+ {
+ return base.AddDefaultValue(this.SqlBuilder.GetTranslationTableName(tableName), this.SqlBuilder.GetTranslationTableName(columnName), defaultValue);
+ }
+ }
+
+ public override bool RenameTable(string oldTableName, string newTableName)
+ {
+ return base.RenameTable(this.SqlBuilder.GetTranslationTableName(oldTableName), this.SqlBuilder.GetTranslationTableName(newTableName));
+ }
+
+ public override bool AddColumnRemark(string columnName, string tableName, string description)
+ {
+ tableName = this.SqlBuilder.GetTranslationTableName(tableName);
+ string sql = string.Format(this.AddColumnRemarkSql, this.SqlBuilder.GetTranslationColumnName(columnName.ToLower(isAutoToLowerCodeFirst)), tableName, description);
+ this.Context.Ado.ExecuteCommand(sql);
+ return true;
+ }
+ public override bool AddTableRemark(string tableName, string description)
+ {
+ tableName = this.SqlBuilder.GetTranslationTableName(tableName);
+ return base.AddTableRemark(tableName, description);
+ }
+ public override bool UpdateColumn(string tableName, DbColumnInfo columnInfo)
+ {
+ ConvertCreateColumnInfo(columnInfo);
+ tableName = this.SqlBuilder.GetTranslationTableName(tableName);
+ var columnName = this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
+ string sql = GetUpdateColumnSql(tableName, columnInfo);
+ this.Context.Ado.ExecuteCommand(sql);
+ var isnull = columnInfo.IsNullable ? " DROP NOT NULL " : " SET NOT NULL ";
+ this.Context.Ado.ExecuteCommand(string.Format("alter table {0} alter {1} {2}", tableName, columnName, isnull));
+ return true;
+ }
+
+ protected override string GetUpdateColumnSql(string tableName, DbColumnInfo columnInfo)
+ {
+ string columnName = this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
+ tableName = this.SqlBuilder.GetTranslationTableName(tableName);
+ string dataSize = GetSize(columnInfo);
+ string dataType = columnInfo.DataType;
+ if (!string.IsNullOrEmpty(dataType))
+ {
+ dataType = " type " + dataType;
+ }
+ string nullType = "";
+ string primaryKey = null;
+ string identity = null;
+ string result = string.Format(this.AlterColumnToTableSql, tableName, columnName, dataType, dataSize, nullType, primaryKey, identity);
+ return result;
+ }
+
+ ///
+ ///by current connection string
+ ///
+ ///
+ ///
+ public override bool CreateDatabase(string databaseName, string databaseDirectory = null)
+ {
+ if (databaseDirectory != null)
+ {
+ if (!FileHelper.IsExistDirectory(databaseDirectory))
+ {
+ FileHelper.CreateDirectory(databaseDirectory);
+ }
+ }
+ var oldDatabaseName = this.Context.Ado.Connection.Database;
+ var connection = this.Context.CurrentConnectionConfig.ConnectionString;
+ if (Regex.Matches(connection, oldDatabaseName).Count > 1)
+ {
+ var builder = new Npgsql.NpgsqlConnectionStringBuilder(connection);
+ builder.Database = "postgres";
+ connection = builder.ConnectionString;
+ }
+ else
+ {
+ connection = connection.Replace(oldDatabaseName, "postgres");
+ }
+ var newDb = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = this.Context.CurrentConnectionConfig.DbType,
+ IsAutoCloseConnection = true,
+ ConnectionString = connection
+ });
+ if (!GetDataBaseList(newDb).Any(it => it.Equals(databaseName, StringComparison.CurrentCultureIgnoreCase)))
+ {
+ var isVast = this.Context?.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.Vastbase;
+ var dbcompatibility = "";
+ if (isVast)
+ {
+ dbcompatibility = " dbcompatibility = 'PG'";
+ }
+ newDb.Ado.ExecuteCommand(string.Format(CreateDataBaseSql, this.SqlBuilder.SqlTranslationLeft + databaseName + this.SqlBuilder.SqlTranslationRight, databaseDirectory) + dbcompatibility);
+ }
+ return true;
+ }
+ public override bool AddRemark(EntityInfo entity)
+ {
+ var db = this.Context;
+ var columns = entity.Columns.Where(it => it.IsIgnore == false).ToList();
+
+ foreach (var item in columns)
+ {
+ if (item.ColumnDescription != null)
+ {
+ db.DbMaintenance.AddColumnRemark(item.DbColumnName, item.DbTableName, item.ColumnDescription);
+
+ }
+ }
+ //table remak
+ if (entity.TableDescription != null)
+ {
+ db.DbMaintenance.AddTableRemark(entity.DbTableName, entity.TableDescription);
+ }
+ return true;
+ }
+ public override bool CreateTable(string tableName, List columns, bool isCreatePrimaryKey = true)
+ {
+ if (columns.HasValue())
+ {
+ foreach (var item in columns)
+ {
+ ConvertCreateColumnInfo(item);
+ if (item.DbColumnName.Equals("GUID", StringComparison.CurrentCultureIgnoreCase) && item.Length == 0)
+ {
+ if (item.DataType?.ToLower() != "uuid")
+ {
+ item.Length = 10;
+ }
+ }
+ }
+ }
+ string sql = GetCreateTableSql(tableName, columns);
+ string primaryKeyInfo = null;
+ if (columns.Any(it => it.IsPrimarykey) && isCreatePrimaryKey)
+ {
+ primaryKeyInfo = string.Format(", Primary key({0})", string.Join(",", columns.Where(it => it.IsPrimarykey).Select(it => this.SqlBuilder.GetTranslationColumnName(it.DbColumnName.ToLower(isAutoToLowerCodeFirst)))));
+
+ }
+ sql = sql.Replace("$PrimaryKey", primaryKeyInfo);
+ this.Context.Ado.ExecuteCommand(sql);
+ return true;
+ }
+ protected override bool IsAnyDefaultValue(string tableName, string columnName, List columns)
+ {
+ var defaultValue = columns.Where(it => it.DbColumnName.Equals(columnName, StringComparison.CurrentCultureIgnoreCase)).First().DefaultValue;
+ if (defaultValue?.StartsWith("NULL::") == true)
+ {
+ return false;
+ }
+ return defaultValue.HasValue();
+ }
+ protected override string GetCreateTableSql(string tableName, List columns)
+ {
+ List columnArray = new List();
+ Check.Exception(columns.IsNullOrEmpty(), "No columns found ");
+ foreach (var item in columns)
+ {
+ string columnName = item.DbColumnName;
+ string dataType = item.DataType;
+ if (dataType == "varchar" && item.Length == 0)
+ {
+ item.Length = 1;
+ }
+ //if (dataType == "uuid")
+ //{
+ // item.Length = 50;
+ // dataType = "varchar";
+ //}
+ string dataSize = item.Length > 0 ? string.Format("({0})", item.Length) : null;
+ if (item.DecimalDigits > 0 && item.Length > 0 && dataType == "numeric")
+ {
+ dataSize = $"({item.Length},{item.DecimalDigits})";
+ }
+ string nullType = item.IsNullable ? this.CreateTableNull : CreateTableNotNull;
+ string primaryKey = null;
+ string addItem = string.Format(this.CreateTableColumn, this.SqlBuilder.GetTranslationColumnName(columnName.ToLower(isAutoToLowerCodeFirst)), dataType, dataSize, nullType, primaryKey, "");
+ if (item.IsIdentity)
+ {
+ if (dataType?.ToLower() == "int")
+ {
+ dataSize = "int4";
+ }
+ else if (dataType?.ToLower() == "long")
+ {
+ dataSize = "int8";
+ }
+ string length = dataType.Substring(dataType.Length - 1);
+ string identityDataType = "serial" + length;
+ addItem = addItem.Replace(dataType, identityDataType);
+ }
+ columnArray.Add(addItem);
+ }
+ string tableString = string.Format(this.CreateTableSql, this.SqlBuilder.GetTranslationTableName(tableName.ToLower(isAutoToLowerCodeFirst)), string.Join(",\r\n", columnArray));
+ return tableString;
+ }
+ public override bool IsAnyConstraint(string constraintName)
+ {
+ throw new NotSupportedException("PgSql IsAnyConstraint NotSupportedException");
+ }
+ public override bool BackupDataBase(string databaseName, string fullFileName)
+ {
+ Check.ThrowNotSupportedException("PgSql BackupDataBase NotSupported");
+ return false;
+ }
+
+ public override List GetColumnInfosByTableName(string tableName, bool isCache = true)
+ {
+ var result = base.GetColumnInfosByTableName(tableName.TrimEnd('"').TrimStart('"').ToLower(), isCache);
+ if (result == null || result.Count() == 0)
+ {
+ result = base.GetColumnInfosByTableName(tableName, isCache);
+ }
+ try
+ {
+ string sql = $@"select
+ kcu.column_name as key_column
+ from information_schema.table_constraints tco
+ join information_schema.key_column_usage kcu
+ on kcu.constraint_name = tco.constraint_name
+ and kcu.constraint_schema = tco.constraint_schema
+ and kcu.constraint_name = tco.constraint_name
+ where tco.constraint_type = 'PRIMARY KEY'
+ and kcu.table_schema='{GetSchema()}' and
+ upper(kcu.table_name)=upper('{tableName.TrimEnd('"').TrimStart('"')}')";
+ List pkList = new List();
+ if (isCache)
+ {
+ pkList = GetListOrCache("GetColumnInfosByTableName_N_Pk" + tableName, sql);
+ }
+ else
+ {
+ pkList = this.Context.Ado.SqlQuery(sql);
+ }
+ if (pkList.Count > 1)
+ {
+ foreach (var item in result)
+ {
+ if (pkList.Select(it => it.ToUpper()).Contains(item.DbColumnName.ToUpper()))
+ {
+ item.IsPrimarykey = true;
+ }
+ }
+ }
+ }
+ catch
+ {
+
+ }
+ return result;
+ }
+ #endregion
+
+ #region Helper
+ private bool isAutoToLowerCodeFirst
+ {
+ get
+ {
+ if (this.Context.CurrentConnectionConfig.MoreSettings == null) return true;
+ else if (
+ this.Context.CurrentConnectionConfig.MoreSettings.PgSqlIsAutoToLower == false &&
+ this.Context.CurrentConnectionConfig.MoreSettings?.PgSqlIsAutoToLowerCodeFirst == false)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ }
+ private string GetSchema()
+ {
+ var schema = "public";
+ var pgSqlIsAutoToLowerSchema = this.Context?.CurrentConnectionConfig?.MoreSettings?.PgSqlIsAutoToLowerSchema == false;
+ if (pgSqlIsAutoToLowerSchema)
+ {
+ if (System.Text.RegularExpressions.Regex.IsMatch(this.Context.CurrentConnectionConfig.ConnectionString, "searchpath=", RegexOptions.IgnoreCase))
+ {
+ var regValue = System.Text.RegularExpressions.Regex.Match(this.Context.CurrentConnectionConfig.ConnectionString, @"searchpath\=(\w+)").Groups[1].Value;
+ if (regValue.HasValue())
+ {
+ schema = regValue;
+ }
+ }
+ else if (System.Text.RegularExpressions.Regex.IsMatch(this.Context.CurrentConnectionConfig.ConnectionString, "search path=", RegexOptions.IgnoreCase))
+ {
+ var regValue = System.Text.RegularExpressions.Regex.Match(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), @"search path\=(\w+)").Groups[1].Value;
+ if (regValue.HasValue())
+ {
+ schema = regValue;
+ }
+ }
+ }
+ else
+ {
+ if (System.Text.RegularExpressions.Regex.IsMatch(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), "searchpath="))
+ {
+ var regValue = System.Text.RegularExpressions.Regex.Match(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), @"searchpath\=(\w+)").Groups[1].Value;
+ if (regValue.HasValue())
+ {
+ schema = regValue;
+ }
+ }
+ else if (System.Text.RegularExpressions.Regex.IsMatch(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), "search path="))
+ {
+ var regValue = System.Text.RegularExpressions.Regex.Match(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), @"search path\=(\w+)").Groups[1].Value;
+ if (regValue.HasValue())
+ {
+ schema = regValue;
+ }
+ }
+ }
+ return schema;
+ }
+ private static void ConvertCreateColumnInfo(DbColumnInfo x)
+ {
+ string[] array = new string[] { "uuid", "int4", "text", "int2", "int8", "date", "bit", "text", "timestamp" };
+
+ if (array.Contains(x.DataType?.ToLower()))
+ {
+ x.Length = 0;
+ x.DecimalDigits = 0;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/Deleteable/TDSQLForOracleODBCDeleteable.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/Deleteable/TDSQLForOracleODBCDeleteable.cs
new file mode 100644
index 0000000000000000000000000000000000000000..7643a046b32831838aba08d22eed78cdcdc2c12f
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/Deleteable/TDSQLForOracleODBCDeleteable.cs
@@ -0,0 +1,14 @@
+using SqlSugar;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public class TDSQLForOracleODBCDeleteable : DeleteableProvider where T : class, new()
+ {
+ protected override List GetIdentityKeys()
+ {
+ return this.EntityInfo.Columns.Where(it => it.OracleSequenceName.HasValue()).Select(it => it.DbColumnName).ToList();
+ }
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/Insertable/TDSQLForOracleODBCInsertable.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/Insertable/TDSQLForOracleODBCInsertable.cs
new file mode 100644
index 0000000000000000000000000000000000000000..bdfb2c8ba548fd44427e24054a3fc9b4be29e408
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/Insertable/TDSQLForOracleODBCInsertable.cs
@@ -0,0 +1,242 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public class TDSQLForOracleODBCInsertable : InsertableProvider where T : class, new()
+ {
+ protected override List GetIdentityKeys()
+ {
+ return this.EntityInfo.Columns.Where(it => it.OracleSequenceName.HasValue()).Select(it => it.DbColumnName).ToList();
+ }
+ protected string GetSeqName()
+ {
+ return this.EntityInfo.Columns.Where(it => it.OracleSequenceName.HasValue()).Select(it => it.OracleSequenceName).First();
+ }
+ protected List GetSeqNames()
+ {
+ return this.EntityInfo.Columns.Where(it => it.OracleSequenceName.HasValue()).Select(it => it.OracleSequenceName).ToList();
+ }
+ public override int ExecuteReturnIdentity()
+ {
+ bool oldIsAuto = AutoBegin();
+
+ InsertBuilder.IsReturnIdentity = true;
+ PreToSql();
+ string sql = InsertBuilder.ToSqlString();
+ if (isIdEntityEnable())
+ {
+ if (sql?.StartsWith("INSERT ALL") == true)
+ {
+ return this.UseParameter().ExecuteCommand();
+ }
+ else
+ {
+ // sql = sql + " RETURNING ID INTO :newId01 ";
+ }
+ //InsertBuilder.Parameters.Add(new SugarParameter(":newId01", 0,true));
+ }
+ RestoreMapping();
+ string identityColumn = GetIdentityColumn();
+ sql = sql.Replace("$PrimaryKey", this.SqlBuilder.GetTranslationColumnName(identityColumn));
+ var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
+ this.Context.Ado.IsDisableMasterSlaveSeparation = true;
+ var result = Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()).ObjToInt();
+ this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
+ After(sql, result);
+ AutoEnd(oldIsAuto);
+ if (isIdEntityEnable())
+ {
+ var name = this.EntityInfo.Columns.First(it => it.IsIdentity).DbColumnName;
+ return this.Context.Ado.GetInt(" SELECT MAX(" + this.InsertBuilder.Builder.GetTranslationColumnName(name) + ") FROM " + this.InsertBuilder.GetTableNameString);
+ }
+ return result;
+ }
+ private bool isIdEntityEnable()
+ {
+ return this.Context.CurrentConnectionConfig?.MoreSettings?.EnableOracleIdentity == true;
+ }
+
+ public override long ExecuteReturnBigIdentity()
+ {
+ bool oldIsAuto = AutoBegin();
+
+ InsertBuilder.IsReturnIdentity = true;
+ PreToSql();
+ string sql = InsertBuilder.ToSqlString();
+ if (isIdEntityEnable())
+ {
+ if (sql?.StartsWith("INSERT ALL") == true)
+ {
+ return this.UseParameter().ExecuteCommand();
+ }
+ else
+ {
+ //sql = sql + " RETURNING ID INTO :newId01 ";
+ }
+ //InsertBuilder.Parameters.Add(new SugarParameter(":newId01", Convert.ToInt64(0), true));
+ }
+ RestoreMapping();
+ string identityColumn = GetIdentityColumn();
+ sql = sql.Replace("$PrimaryKey", this.SqlBuilder.GetTranslationColumnName(identityColumn));
+ var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
+ this.Context.Ado.IsDisableMasterSlaveSeparation = true;
+ var result = Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()).ObjToLong();
+ this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
+ After(sql, result);
+ AutoEnd(oldIsAuto);
+ if (isIdEntityEnable())
+ {
+ var name = this.EntityInfo.Columns.First(it => it.IsIdentity).DbColumnName;
+ return this.Context.Ado.GetInt(" SELECT MAX(" + this.InsertBuilder.Builder.GetTranslationColumnName(name) + ") FROM " + this.InsertBuilder.GetTableNameString);
+ }
+ return result;
+ }
+
+ public async override Task ExecuteReturnIdentityAsync()
+ {
+ bool oldIsAuto = AutoBegin();
+
+ InsertBuilder.IsReturnIdentity = true;
+ PreToSql();
+ string sql = InsertBuilder.ToSqlString();
+ if (isIdEntityEnable())
+ {
+ if (sql?.StartsWith("INSERT ALL") == true)
+ {
+ return await this.UseParameter().ExecuteCommandAsync();
+ }
+ else
+ {
+ //sql = sql + " RETURNING ID INTO :newId01 ";
+ }
+ //InsertBuilder.Parameters.Add(new SugarParameter(":newId01", 0, true));
+ }
+ RestoreMapping();
+ string identityColumn = GetIdentityColumn();
+ sql = sql.Replace("$PrimaryKey", this.SqlBuilder.GetTranslationColumnName(identityColumn));
+ var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
+ this.Context.Ado.IsDisableMasterSlaveSeparation = true;
+ var result = (await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray())).ObjToInt();
+ this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
+ After(sql, result);
+ AutoEnd(oldIsAuto);
+ if (isIdEntityEnable())
+ {
+ var name = this.EntityInfo.Columns.First(it => it.IsIdentity).DbColumnName;
+ return await this.Context.Ado.GetIntAsync(" SELECT MAX(" + this.InsertBuilder.Builder.GetTranslationColumnName(name) + ") FROM " + this.InsertBuilder.GetTableNameString);
+ }
+ return result;
+ }
+
+ public async override Task ExecuteReturnBigIdentityAsync()
+ {
+ bool oldIsAuto = AutoBegin();
+
+ InsertBuilder.IsReturnIdentity = true;
+ PreToSql();
+ string sql = InsertBuilder.ToSqlString();
+ if (isIdEntityEnable())
+ {
+ if (sql?.StartsWith("INSERT ALL") == true)
+ {
+ return await this.UseParameter().ExecuteCommandAsync();
+ }
+ else
+ {
+ //sql = sql + " RETURNING ID INTO :newId01 ";
+ }
+ //InsertBuilder.Parameters.Add(new SugarParameter(":newId01", Convert.ToInt64(0), true));
+ }
+ RestoreMapping();
+ string identityColumn = GetIdentityColumn();
+ sql = sql.Replace("$PrimaryKey", this.SqlBuilder.GetTranslationColumnName(identityColumn));
+ var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
+ this.Context.Ado.IsDisableMasterSlaveSeparation = true;
+ var result = (await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray())).ObjToLong();
+ this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
+ After(sql, result);
+ AutoEnd(oldIsAuto);
+ if (isIdEntityEnable())
+ {
+ var name = this.EntityInfo.Columns.First(it => it.IsIdentity).DbColumnName;
+ return this.Context.Ado.GetInt(" SELECT MAX(" + this.InsertBuilder.Builder.GetTranslationColumnName(name) + ") FROM " + this.InsertBuilder.GetTableNameString);
+ }
+ return result;
+ }
+
+ private void AutoEnd(bool oldIsAuto)
+ {
+ if (oldIsAuto)
+ {
+ this.Context.Context.CurrentConnectionConfig.IsAutoCloseConnection = oldIsAuto;
+ if (this.Ado.Transaction == null)
+ this.Context.Ado.Close();
+ }
+ }
+
+ private bool AutoBegin()
+ {
+ var oldIsAuto = this.Context.Context.CurrentConnectionConfig.IsAutoCloseConnection;
+ if (this.Context.Context.CurrentConnectionConfig.IsAutoCloseConnection)
+ {
+ this.Context.Context.CurrentConnectionConfig.IsAutoCloseConnection = false;
+ }
+
+ return oldIsAuto;
+ }
+ //private object GetSeqValue(string seqName)
+ //{
+ // return Ado.GetScalar(" SELECT " + seqName + ".currval FROM DUAL");
+ //}
+ protected override void PreToSql()
+ {
+ var identities = GetSeqNames();
+ var insertCount = InsertObjs.Count();
+ InsertBuilder.OracleSeqInfoList = new Dictionary();
+ if ((identities.HasValue() && insertCount > 1) || InsertBuilder.IsBlukCopy)
+ {
+ Check.Exception(identities.Count != identities.Distinct().Count(), "The field sequence needs to be unique");
+ foreach (var seqName in identities)
+ {
+ int seqBeginValue = 0;
+ seqBeginValue = this.Ado.GetInt("select " + seqName + ".Nextval from dual");
+ //Console.WriteLine(seqBeginValue);
+ var nextLength = insertCount - 1;
+ if (nextLength > 0)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.AppendLine(" select " + seqName + ".nextval,t.* from (");
+ for (int i = 0; i < nextLength; i++)
+ {
+ sb.AppendLine(" select 1 from dual");
+ if (i < (nextLength - 1))
+ {
+ sb.AppendLine("union all");
+ }
+ }
+ sb.AppendLine(" )t");
+ this.Ado.SqlQuery(sb.ToString());
+ }
+ InsertBuilder.OracleSeqInfoList.Add(seqName, seqBeginValue);
+ }
+ }
+ base.PreToSql();
+ }
+
+
+ private string GetIdentityColumn()
+ {
+ var identityColumn = GetIdentityKeys().FirstOrDefault();
+ if (identityColumn == null)
+ {
+ var columns = this.Context.DbMaintenance.GetColumnInfosByTableName(InsertBuilder.GetTableNameString);
+ identityColumn = columns.First(it => it.IsIdentity || it.IsPrimarykey).DbColumnName;
+ }
+ return identityColumn;
+ }
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/Queryable/TDSQLForOracleODBCQueryable.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/Queryable/TDSQLForOracleODBCQueryable.cs
new file mode 100644
index 0000000000000000000000000000000000000000..21545e0288271a4a489a6e7b323d3a5d0367c586
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/Queryable/TDSQLForOracleODBCQueryable.cs
@@ -0,0 +1,62 @@
+using SqlSugar;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+ public override ISugarQueryable With(string withString)
+ {
+ return this;
+ }
+ protected override List GetIdentityKeys()
+ {
+ return this.EntityInfo.Columns.Where(it => it.OracleSequenceName.HasValue()).Select(it => it.DbColumnName).ToList();
+ }
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+ public class TDSQLForOracleODBCQueryable : QueryableProvider
+ {
+
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCBlukCopy.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCBlukCopy.cs
new file mode 100644
index 0000000000000000000000000000000000000000..7fe776440ef60351b1bf9550ebb7014c04a5371a
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCBlukCopy.cs
@@ -0,0 +1,153 @@
+using Microsoft.Data.SqlClient;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public class TDSQLForOracleODBCBlukCopy
+ {
+ internal List> DbColumnInfoList { get; set; }
+ internal SqlSugarProvider Context { get; set; }
+ internal ISqlBuilder Builder { get; set; }
+ internal InsertBuilder InsertBuilder { get; set; }
+ internal object[] Inserts { get; set; }
+
+ public int ExecuteBulkCopy()
+ {
+ if (DbColumnInfoList == null || DbColumnInfoList.Count == 0) return 0;
+
+ if (Inserts.First().GetType() == typeof(DataTable))
+ {
+ return WriteToServer();
+ }
+ DataTable dt = GetCopyData();
+ SqlBulkCopy bulkCopy = GetBulkCopyInstance();
+ bulkCopy.DestinationTableName = InsertBuilder.GetTableNameString;
+ try
+ {
+ bulkCopy.WriteToServer(dt);
+ }
+ catch (Exception ex)
+ {
+ CloseDb();
+ throw ex;
+ }
+ CloseDb();
+ return DbColumnInfoList.Count;
+ }
+
+ public async Task ExecuteBulkCopyAsync()
+ {
+ if (DbColumnInfoList == null || DbColumnInfoList.Count == 0) return 0;
+
+ if (Inserts.First().GetType() == typeof(DataTable))
+ {
+ return WriteToServer();
+ }
+ DataTable dt = GetCopyData();
+ SqlBulkCopy bulkCopy = GetBulkCopyInstance();
+ bulkCopy.DestinationTableName = InsertBuilder.GetTableNameString;
+ try
+ {
+ await bulkCopy.WriteToServerAsync(dt);
+ }
+ catch (Exception ex)
+ {
+ CloseDb();
+ throw ex;
+ }
+ CloseDb();
+ return DbColumnInfoList.Count;
+ }
+
+ private int WriteToServer()
+ {
+ var dt = this.Inserts.First() as DataTable;
+ if (dt == null)
+ return 0;
+ Check.Exception(dt.TableName == "Table", "dt.TableName can't be null ");
+ dt = GetCopyWriteDataTable(dt);
+ SqlBulkCopy copy = GetBulkCopyInstance();
+ copy.DestinationTableName = this.Builder.GetTranslationColumnName(dt.TableName);
+ copy.WriteToServer(dt);
+ CloseDb();
+ return dt.Rows.Count;
+ }
+ private DataTable GetCopyWriteDataTable(DataTable dt)
+ {
+ var result = this.Context.Ado.GetDataTable("select top 0 * from " + this.Builder.GetTranslationColumnName(dt.TableName));
+ foreach (DataRow item in dt.Rows)
+ {
+ DataRow dr = result.NewRow();
+ foreach (DataColumn column in result.Columns)
+ {
+
+ if (dt.Columns.Cast().Select(it => it.ColumnName.ToLower()).Contains(column.ColumnName.ToLower()))
+ {
+ dr[column.ColumnName] = item[column.ColumnName];
+ if (dr[column.ColumnName] == null)
+ {
+ dr[column.ColumnName] = DBNull.Value;
+ }
+ }
+ }
+ result.Rows.Add(dr);
+ }
+ result.TableName = dt.TableName;
+ return result;
+ }
+ private SqlBulkCopy GetBulkCopyInstance()
+ {
+ SqlBulkCopy copy;
+ if (this.Context.Ado.Transaction == null)
+ {
+ copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection);
+ }
+ else
+ {
+ copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection, SqlBulkCopyOptions.CheckConstraints, (SqlTransaction)this.Context.Ado.Transaction);
+ }
+ if (this.Context.Ado.Connection.State == ConnectionState.Closed)
+ {
+ this.Context.Ado.Connection.Open();
+ }
+ copy.BulkCopyTimeout = this.Context.Ado.CommandTimeOut;
+ return copy;
+ }
+ private DataTable GetCopyData()
+ {
+ var dt = this.Context.Ado.GetDataTable("select top 0 * from " + InsertBuilder.GetTableNameString);
+ foreach (var rowInfos in DbColumnInfoList)
+ {
+ var dr = dt.NewRow();
+ foreach (var value in rowInfos)
+ {
+ if (value.Value != null && UtilMethods.GetUnderType(value.Value.GetType()) == UtilConstants.DateType)
+ {
+ if (value.Value != null && value.Value.ToString() == DateTime.MinValue.ToString())
+ {
+ value.Value = Convert.ToDateTime("1753/01/01");
+ }
+ }
+ if (value.Value == null)
+ {
+ value.Value = DBNull.Value;
+ }
+ dr[value.DbColumnName] = value.Value;
+ }
+ dt.Rows.Add(dr);
+ }
+ return dt;
+ }
+ private void CloseDb()
+ {
+ if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection && this.Context.Ado.Transaction == null)
+ {
+ this.Context.Ado.Connection.Close();
+ }
+ }
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCBuilder.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCBuilder.cs
new file mode 100644
index 0000000000000000000000000000000000000000..6bd3c6453e23d2e2e542eab2b98555c7a897eb4f
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCBuilder.cs
@@ -0,0 +1,74 @@
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public class TDSQLForOracleODBCBuilder : SqlBuilderProvider
+ {
+ public override string SqlParameterKeyWord
+ {
+ get
+ {
+ return ":";
+ }
+ }
+ public override string SqlDateNow
+ {
+ get
+ {
+ return "sysdate";
+ }
+ }
+ public override string FullSqlDateNow
+ {
+ get
+ {
+ return "select systimestamp from dual";
+ }
+ }
+ public override string SqlTranslationLeft { get { return "\""; } }
+ public override string SqlTranslationRight { get { return "\""; } }
+ public override string GetTranslationTableName(string name)
+ {
+ var result = base.GetTranslationTableName(name);
+ if (result.Contains("(") && result.Contains(")"))
+ return result;
+ else
+ return result.ToUpper(IsUppper);
+ }
+ public override string GetTranslationColumnName(string entityName, string propertyName)
+ {
+ var result = base.GetTranslationColumnName(entityName, propertyName);
+ return result.ToUpper(IsUppper);
+ }
+ public override string GetTranslationColumnName(string propertyName)
+ {
+ var result = base.GetTranslationColumnName(propertyName);
+ return result.ToUpper(IsUppper);
+ }
+ public override string RemoveParentheses(string sql)
+ {
+ if (sql.StartsWith("(") && sql.EndsWith(")"))
+ {
+ sql = sql.Substring(1, sql.Length - 2);
+ }
+
+ return sql;
+ }
+ #region Helper
+ public bool IsUppper
+ {
+ get
+ {
+ if (this.Context.CurrentConnectionConfig.MoreSettings == null)
+ {
+ return true;
+ }
+ else
+ {
+ return this.Context.CurrentConnectionConfig.MoreSettings.IsAutoToUpper == true;
+ }
+ }
+ }
+ #endregion
+
+ }
+
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCDeleteBuilder.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCDeleteBuilder.cs
new file mode 100644
index 0000000000000000000000000000000000000000..69e6710ef9168fc98d7ab20adf3ab37a281599a2
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCDeleteBuilder.cs
@@ -0,0 +1,7 @@
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public class TDSQLForOracleODBCDeleteBuilder : DeleteBuilder
+ {
+
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCExpressionContext.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCExpressionContext.cs
new file mode 100644
index 0000000000000000000000000000000000000000..cad7418e2a6dabc87ecdbcf20d635c5d7e848159
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForOracleODBC/TDSQLForOracleODBC/SqlBuilder/TDSQLForOracleODBCExpressionContext.cs
@@ -0,0 +1,467 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace SqlSugar.TDSQLForOracleODBC
+{
+ public partial class TDSQLForOracleODBCExpressionContext : ExpressionContext, ILambdaExpressions
+ {
+ public SqlSugarProvider Context { get; set; }
+ public TDSQLForOracleODBCExpressionContext()
+ {
+ base.DbMehtods = new OceanBaseForOracleMethod();
+ base.Case = new ExpressionContextCase();
+ }
+ public override string SqlParameterKeyWord
+ {
+ get
+ {
+ return ":";
+ }
+ }
+ public override string SqlTranslationLeft { get { return "\""; } }
+ public override string SqlTranslationRight { get { return "\""; } }
+ public override string GetTranslationTableName(string entityName, bool isMapping = true)
+ {
+ return base.GetTranslationTableName(entityName, isMapping).ToUpper(IsUppper);
+ }
+ public override string GetTranslationColumnName(string columnName)
+ {
+ if (columnName == "systimestamp")
+ {
+ return columnName;
+ }
+ if (columnName.Contains(":"))
+ return base.GetTranslationColumnName(columnName);
+ else if (columnName.Contains("\".\""))
+ {
+ return columnName;
+ }
+ else
+ return base.GetTranslationColumnName(columnName).ToUpper(IsUppper);
+ }
+ public override string GetDbColumnName(string entityName, string propertyName)
+ {
+ return base.GetDbColumnName(entityName, propertyName).ToUpper(IsUppper);
+ }
+ public override bool IsTranslationText(string name)
+ {
+ if (!string.IsNullOrEmpty(name) && name.ToLower() == "sysdate")
+ {
+ return true;
+ }
+ var result = name.IsContainsIn(SqlTranslationLeft, SqlTranslationRight, UtilConstants.Space, ExpressionConst.LeftParenthesis, ExpressionConst.RightParenthesis);
+ return result;
+ }
+ public bool IsUppper
+ {
+ get
+ {
+ if (this.SugarContext?.Context?.Context?.CurrentConnectionConfig?.MoreSettings == null)
+ {
+ return true;
+ }
+ else
+ {
+ return this.SugarContext?.Context?.Context?.CurrentConnectionConfig?.MoreSettings.IsAutoToUpper == true;
+ }
+ }
+ }
+
+ public override string GetLimit()
+ {
+ int num = 1;
+ if (this.Case?.Num > 1)
+ {
+ num = this.Case.Num;
+ }
+ return (this.Case?.HasWhere == true ? "AND" : "WHERE") + " ROWNUM=" + num;
+ }
+ }
+ public partial class OceanBaseForOracleMethod : DefaultDbMethod, IDbMethods
+ {
+ public override string UNIX_TIMESTAMP(MethodCallExpressionModel model)
+ {
+ var parameterNameA = model.Args[0].MemberName;
+ return $" (CAST({parameterNameA} AS DATE) - DATE '1970-01-01') * 86400 ";
+ }
+ public override string IsNullOrEmpty(MethodCallExpressionModel model)
+ {
+ var parameter = model.Args[0];
+ return string.Format("( {0} IS NULL )", parameter.MemberName);
+ }
+ public override string WeekOfYear(MethodCallExpressionModel mode)
+ {
+ var parameterNameA = mode.Args[0].MemberName;
+ return $"TO_NUMBER(TO_CHAR({parameterNameA}, 'WW')) ";
+ }
+ public override string BitwiseAnd(MethodCallExpressionModel model)
+ {
+ var parameter = model.Args[0];
+ var parameter2 = model.Args[1];
+ return string.Format(" BITAND({0},{1}) ", parameter.MemberName, parameter2.MemberName);
+ }
+ public override string BitwiseInclusiveOR(MethodCallExpressionModel model)
+ {
+ var parameter = model.Args[0];
+ var parameter2 = model.Args[1];
+ return string.Format(" BITOR({0},{1}) ", parameter.MemberName, parameter2.MemberName);
+ }
+ public override string ParameterKeyWord { get; set; } = ":";
+ public override string Modulo(MethodCallExpressionModel model)
+ {
+ return " MOD(" + model.Args[0].MemberName + " , " + model.Args[1].MemberName + ")";
+ }
+ public override string GetStringJoinSelector(string result, string separator)
+ {
+ if (result.Contains(","))
+ {
+ return $"listagg(to_char({result.Split(',').First()}),'{separator}') within group(order by {result.Split(',').Last()}) ";
+ }
+ else
+ {
+ return $"listagg(to_char({result}),'{separator}') within group(order by {result}) ";
+ }
+ }
+ public override string HasValue(MethodCallExpressionModel model)
+ {
+ var parameter = model.Args[0];
+ return string.Format("( {0} IS NOT NULL ) ", parameter.MemberName);
+ }
+
+ public override string DateDiff(MethodCallExpressionModel model)
+ {
+ var parameter = (DateType)(Enum.Parse(typeof(DateType), model.Args[0].MemberValue.ObjToString()));
+ var begin = model.Args[1].MemberName;
+ var end = model.Args[2].MemberName;
+ switch (parameter)
+ {
+ case DateType.Year:
+ return $" ( cast((months_between( {end} , {begin}))/12 as number(9,0) ) )";
+ case DateType.Month:
+ return $" ( cast((months_between( {end} , {begin})) as number(9,0) ) )";
+ case DateType.Day:
+ return $" ( ROUND(TO_NUMBER(cast({end} as date) - cast({begin} as date))) )";
+ case DateType.Hour:
+ return $" ( ROUND(TO_NUMBER(cast({end} as date) - cast({begin} as date)) * 24) )";
+ case DateType.Minute:
+ return $" ( ROUND(TO_NUMBER(cast({end} as date) - cast({begin} as date)) * 24 * 60) )";
+ case DateType.Second:
+ return $" ( ROUND(TO_NUMBER(cast({end} as date) - cast({begin} as date)) * 24 * 60 * 60) )";
+ case DateType.Millisecond:
+ return $" ( ROUND(TO_NUMBER(cast({end} as date) - cast({begin} as date)) * 24 * 60 * 60 * 60) )";
+ default:
+ break;
+ }
+ throw new Exception(parameter + " datediff no support");
+ }
+ private void PageEach(IEnumerable pageItems, int pageSize, Action> action)
+ {
+ if (pageItems != null && pageItems.Any())
+ {
+ int totalRecord = pageItems.Count();
+ int pageCount = (totalRecord + pageSize - 1) / pageSize;
+ for (int i = 1; i <= pageCount; i++)
+ {
+ var list = pageItems.Skip((i - 1) * pageSize).Take(pageSize).ToList();
+ action(list);
+ }
+ }
+ }
+ public override string ContainsArray(MethodCallExpressionModel model)
+ {
+ if (model.Args[0].MemberValue == null)
+ {
+ return base.ContainsArray(model);
+ }
+ var inValueIEnumerable = ((IEnumerable)model.Args[0].MemberValue).Cast