mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-30 12:47:57 +08:00
Update pgsql unit
This commit is contained in:
parent
cf228b4155
commit
abd736aa9b
@ -100,6 +100,7 @@
|
|||||||
<Compile Include="Models\ViewOrder.cs" />
|
<Compile Include="Models\ViewOrder.cs" />
|
||||||
<Compile Include="Config.cs" />
|
<Compile Include="Config.cs" />
|
||||||
<Compile Include="UnitTest\UAopTest.cs" />
|
<Compile Include="UnitTest\UAopTest.cs" />
|
||||||
|
<Compile Include="UnitTest\UCustom01.cs" />
|
||||||
<Compile Include="UnitTest\USave.cs" />
|
<Compile Include="UnitTest\USave.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
UCustom01.Init();
|
||||||
Save();
|
Save();
|
||||||
CodeFirst();
|
CodeFirst();
|
||||||
Updateable();
|
Updateable();
|
||||||
|
52
Src/Asp.Net/PgSqlTest/UnitTest/UCustom01.cs
Normal file
52
Src/Asp.Net/PgSqlTest/UnitTest/UCustom01.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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,
|
DbType = DbType.PostgreSQL,
|
||||||
ConnectionString = Config.ConnectionString,
|
ConnectionString = Config.ConnectionString,
|
||||||
|
@ -81,7 +81,7 @@ namespace SqlSugar
|
|||||||
.MappingTables
|
.MappingTables
|
||||||
.FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase));
|
.FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase));
|
||||||
name = (mappingInfo == null ? name : mappingInfo.DbTableName);
|
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));
|
return string.Join(".", name.ToLower(isAutoToLower).Split('.').Select(it => SqlTranslationLeft + it + SqlTranslationRight));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user