mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-09 15:17:57 +08:00
60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
![]() |
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Net;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace OrmTest
|
|||
|
{
|
|||
|
internal class UnitValueObject
|
|||
|
{
|
|||
|
public static void Init()
|
|||
|
{
|
|||
|
var db = NewUnitTest.Db;
|
|||
|
db.CodeFirst.InitTables<UnitCustomeradfafas>();
|
|||
|
db.DbMaintenance.TruncateTable<UnitCustomeradfafas>();
|
|||
|
db.Insertable(new UnitCustomeradfafas()
|
|||
|
{
|
|||
|
CustomerId=1,
|
|||
|
Name="name",
|
|||
|
Address=new UnitAddressadfafa()
|
|||
|
{
|
|||
|
City="city",
|
|||
|
Street= "street",
|
|||
|
ZipCode= "zipCode"
|
|||
|
}
|
|||
|
|
|||
|
}).ExecuteCommand();
|
|||
|
db.Updateable(new UnitCustomeradfafas()
|
|||
|
{
|
|||
|
CustomerId = 1,
|
|||
|
Name = "name2",
|
|||
|
Address = new UnitAddressadfafa()
|
|||
|
{
|
|||
|
City = "city2",
|
|||
|
Street = "street2",
|
|||
|
ZipCode = "zipCode2"
|
|||
|
}
|
|||
|
|
|||
|
}).ExecuteCommand();
|
|||
|
var list=db.Queryable<UnitCustomeradfafas>().ToList();
|
|||
|
}
|
|||
|
}
|
|||
|
public class UnitAddressadfafa
|
|||
|
{
|
|||
|
public string Street { get; set; }
|
|||
|
public string City { get; set; }
|
|||
|
public string ZipCode { get; set; }
|
|||
|
|
|||
|
}
|
|||
|
public class UnitCustomeradfafas
|
|||
|
{
|
|||
|
[SqlSugar.SugarColumn(IsPrimaryKey =true)]
|
|||
|
public int CustomerId { get; set; }
|
|||
|
public string Name { get; set; }
|
|||
|
[SqlSugar.SugarColumn(IsOwnsOne =true)]
|
|||
|
public UnitAddressadfafa Address { get; set; }
|
|||
|
}
|
|||
|
}
|