mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-27 03:09:34 +08:00
Add demo
This commit is contained in:
@@ -32,6 +32,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
Unita1ddys.Init();
|
||||||
Unit1sdgsaaysdfa.Init();
|
Unit1sdgsaaysdfa.Init();
|
||||||
UnitBulkMergeaa.Init();
|
UnitBulkMergeaa.Init();
|
||||||
Unitadsfayasdfaaay.Init();
|
Unitadsfayasdfaaay.Init();
|
||||||
|
|||||||
54
Src/Asp.NetCore2/PgSqlTest/UserTestCases/Unita1ddys.cs
Normal file
54
Src/Asp.NetCore2/PgSqlTest/UserTestCases/Unita1ddys.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using Microsoft.Identity.Client;
|
||||||
|
using Npgsql;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
internal class Unita1ddys
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var db = NewUnitTest.Db;//用于创建schema和删除schema
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
db.Ado.ExecuteCommand("CREATE SCHEMA testcm");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
var newdb = NewUnitTest.Db.CopyNew();//新db指定schema实现crud
|
||||||
|
newdb.CurrentConnectionConfig.ConnectionString = Config.ConnectionString + ";searchpath=testcm";
|
||||||
|
newdb.CodeFirst.InitTables<Unitsdfafayas>();
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
Unitsdfafayas entity = new Unitsdfafayas()
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid().ToString(),
|
||||||
|
Annex = new List<string>() { "12312321332" }
|
||||||
|
};
|
||||||
|
newdb.Insertable(entity).ExecuteCommand();
|
||||||
|
}
|
||||||
|
var communityEntities = newdb.Queryable<Unitsdfafayas>().ToList();
|
||||||
|
|
||||||
|
var x = newdb.Storageable(communityEntities).ToStorage();
|
||||||
|
x.AsInsertable.ExecuteCommand();
|
||||||
|
x.AsUpdateable.ExecuteCommand();
|
||||||
|
|
||||||
|
System.Drawing.Point
|
||||||
|
}
|
||||||
|
public class Unitsdfafayas
|
||||||
|
{
|
||||||
|
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnName = "annex", ColumnDataType = "JSONB", IsJson = true)]
|
||||||
|
public List<string> Annex { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user