mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-27 16:50:33 +08:00
Support Json
This commit is contained in:
@@ -8,7 +8,7 @@ namespace OrmTest
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
OldTestMain.Init();
|
||||
//OldTestMain.Init();
|
||||
|
||||
//Demo
|
||||
Demo1_SqlSugarClient.Init();
|
||||
|
||||
@@ -140,6 +140,7 @@
|
||||
<Compile Include="OldTest\UnitTest\Setting\MapColumn.cs" />
|
||||
<Compile Include="OldTest\UnitTest\Setting\MapTable.cs" />
|
||||
<Compile Include="OldTest\UnitTest\Update.cs" />
|
||||
<Compile Include="UnitTest\UJson.cs" />
|
||||
<Compile Include="UnitTest\Main.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -7,9 +8,23 @@ namespace OrmTest
|
||||
{
|
||||
public partial class NewUnitTest
|
||||
{
|
||||
public static SqlSugarClient Db=> new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
DbType = DbType.SqlServer,
|
||||
ConnectionString = Config.ConnectionString,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
AopEvents = new AopEvents
|
||||
{
|
||||
OnLogExecuting = (sql, p) =>
|
||||
{
|
||||
Console.WriteLine(sql);
|
||||
}
|
||||
}
|
||||
});
|
||||
public static void Init()
|
||||
{
|
||||
|
||||
Json();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
31
Src/Asp.Net/SqlServerTest/UnitTest/UJson.cs
Normal file
31
Src/Asp.Net/SqlServerTest/UnitTest/UJson.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public partial class NewUnitTest
|
||||
{
|
||||
|
||||
public static void Json()
|
||||
{
|
||||
Db.CodeFirst.InitTables<JsonTest>();
|
||||
Db.DbMaintenance.TruncateTable("JsonTest");
|
||||
Db.Insertable(new JsonTest() { Order = new Order { Id = 1, Name = "order1" } }).ExecuteCommand();
|
||||
var list = Db.Queryable<JsonTest>().ToList();
|
||||
Db.Updateable(new JsonTest() { Id=1,Order = new Order { Id = 2, Name = "order2" } }).ExecuteCommand();
|
||||
var list2 = Db.Queryable<JsonTest>().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class JsonTest
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
[SqlSugar.SugarColumn(ColumnDataType = "varchar(max)", IsJson = true)]
|
||||
public Order Order { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user