Update pgsql unit

This commit is contained in:
sunkaixuan 2022-03-02 14:55:38 +08:00
parent cf228b4155
commit abd736aa9b
5 changed files with 56 additions and 2 deletions

View File

@ -100,6 +100,7 @@
<Compile Include="Models\ViewOrder.cs" />
<Compile Include="Config.cs" />
<Compile Include="UnitTest\UAopTest.cs" />
<Compile Include="UnitTest\UCustom01.cs" />
<Compile Include="UnitTest\USave.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -31,6 +31,7 @@ namespace OrmTest
}
public static void Init()
{
UCustom01.Init();
Save();
CodeFirst();
Updateable();

View File

@ -0,0 +1,52 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class UCustom01
{
public static void Init()
{
var db = new SqlSugarScope(new SqlSugar.ConnectionConfig()
{
ConnectionString = Config.ConnectionString,
DbType = SqlSugar.DbType.PostgreSQL,
IsAutoCloseConnection = true
});
db.Aop.OnLogExecuted = (s, p) =>
{
Console.WriteLine(s);
};
//db.CodeFirst.InitTables<User_Test001>();
var list=db.Queryable<User_Test001>().ToList();
var dt = new DataTable();
dt.Columns.Add("ID",typeof(int));
dt.Columns.Add("UserName");
dt.TableName = "public.unitUser_Test001"; //设置表名
var addRow = dt.NewRow();
addRow["ID"] = 1;
addRow["UserName"] = "a";
dt.Rows.Add(addRow);//添加娄据
var x = db.Storageable(dt).WhereColumns("id").ToStorage();//id作为主键
}
[SugarTable("public.unitUser_Test001")]
public class User_Test001
{
public int ID { get; set; }
public string UserName { get; set; }
}
}
}

View File

@ -40,7 +40,7 @@ namespace OrmTest
}
}
});
public static SqlSugarClient singleDb = new SqlSugarClient(new ConnectionConfig()
public static SqlSugarScope singleDb = new SqlSugarScope(new ConnectionConfig()
{
DbType = DbType.PostgreSQL,
ConnectionString = Config.ConnectionString,

View File

@ -81,7 +81,7 @@ namespace SqlSugar
.MappingTables
.FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase));
name = (mappingInfo == null ? name : mappingInfo.DbTableName);
if (name.Contains(".")&& !name.Contains("("))
if (name.Contains(".")&& !name.Contains("(")&&!name.Contains("\".\""))
{
return string.Join(".", name.ToLower(isAutoToLower).Split('.').Select(it => SqlTranslationLeft + it + SqlTranslationRight));
}