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(); Db.DbMaintenance.TruncateTable(); Db.Insertable(new UnitJsonTest() { Id=1,Order2 = new Order { Id = 1, Name = "order1" } }).ExecuteCommand(); var list = Db.Queryable().ToList(); UValidate.Check("order1", list.First().Order2.Name, "Json"); Db.Updateable(new UnitJsonTest() { Id = 1, Order2 = new Order { Id = 2, Name = "order2" } }).ExecuteCommand(); list= Db.Queryable().ToList(); UValidate.Check("order2", list.First().Order2.Name, "Json"); var list2 = Db.Queryable().ToList(); } } public class UnitJsonTest { [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int Id { get; set; } [SqlSugar.SugarColumn(ColumnDataType = "varchar(2000)", IsJson = true)] public Order Order2 { get; set; } } }