SqlSugar源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

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