*增加TDSQLForPGODBC的支持

This commit is contained in:
guoshun.du
2024-09-20 15:52:10 +08:00
parent 05788a10f2
commit dbb1945b03
31 changed files with 5568 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TDSQLForPGOBDCTest
{
/// <summary>
/// Setting up the database name does not require you to create the database
/// 设置好数据库名不需要你去手动建库
/// </summary>
public class Config
{
/// <summary>
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
public static string ConnectionString = "Driver={TDSQL PostgreSQL Unicode(x64)};Server=172.19.4.36;Port=11001;Database=xirdb;Uid=xir_app;Pwd=xpar;ConnSettings=set search_path to XIR_APP;";
/// <summary>
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
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";
/// <summary>
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
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";
}
}

View File

@@ -0,0 +1,51 @@
using SqlSugar;
using SqlSugar.TDSQLForPGODBC;
namespace TDSQLForPGOBDCTest
{
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.TDSQLForPGODBC,//Oracle 模式用这个 如果是MySql 模式用DbType.MySql
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings()
{
PgSqlIsAutoToLower = false,//增删查改支持驼峰表
PgSqlIsAutoToLowerCodeFirst = false, // 建表建驼峰表。5.1.3.30
}
});
db.Aop.OnLogExecuted = (s, p) =>
{
Console.WriteLine(s);
};
var list = db.Queryable<TSYS_USER>().ToList();
var page1 = db.Queryable<TSYS_USER>().ToOffsetPage(1, 30);
db.Insertable<TSYS_USER>(new TSYS_USER
{
U_ID = "DGSSqlsugar",
U_NAME = "杜国舜SqlSugar适配",
U_EMAIL = "dd2@"
}).ExecuteCommand();
db.Updateable<TSYS_USER>(new TSYS_USER
{
U_ID = "DGSSqlsugar",
U_NAME = "杜国舜SqlSugar适配修改后",
U_EMAIL = "dd2@"
}).ExecuteCommand();
db.Deleteable<TSYS_USER>().Where(m => m.U_ID == "DGSSqlsugar").ExecuteCommand();
}
}
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SqlSugar.TDSQLForPGODBC\SqlSugar.TDSQLForPGODBC.csproj" />
<ProjectReference Include="..\SqlSugar\SqlSugar.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,58 @@
using SqlSugar;
using System;
namespace TDSQLForPGOBDCTest
{
///<summary>
/// XIR用户表
///</summary>
[SugarTable("TSYS_USER")]
public partial class TSYS_USER
{
public TSYS_USER()
{
}
/// <summary>
/// Desc:
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsNullable = false, IsPrimaryKey = true, Length = 30)]
public string U_ID { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(IsNullable = true, Length = 50)]
public string U_NAME { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(IsNullable = true, Length = 1)]
public string U_STATE { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(IsNullable = true, Length = 2000)]
public string U_REMARK { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(IsNullable = true, Length = 100)]
public string U_EMAIL { get; set; }
}
}