mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Update user demo
This commit is contained in:
parent
2f4a6d0bd2
commit
cac3a9f5b7
@ -0,0 +1,80 @@
|
|||||||
|
using SqlSugar.DbConvert;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
internal class UnitValueObject
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var db = NewUnitTest.Db;
|
||||||
|
|
||||||
|
db.CodeFirst.InitTables<UnitafasMyEntity>();
|
||||||
|
db.Insertable(new UnitafasMyEntity()
|
||||||
|
{
|
||||||
|
Id=Guid.NewGuid(),
|
||||||
|
P0="a",
|
||||||
|
P1=1,
|
||||||
|
MyVO=new MyVO() {
|
||||||
|
GuidP1=Guid.NewGuid(),
|
||||||
|
GuidP2=Guid.NewGuid(),
|
||||||
|
VoId=Guid.NewGuid()
|
||||||
|
}
|
||||||
|
}).ExecuteCommand();
|
||||||
|
var list5 = db.Queryable<UnitafasMyEntity>()
|
||||||
|
.Select(e => new
|
||||||
|
{
|
||||||
|
e.Id,
|
||||||
|
e.MyVO.GuidP1,
|
||||||
|
e.MyVO.GuidP2
|
||||||
|
})
|
||||||
|
.ToListAsync().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class UnitafasMyEntity
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public string P0 { get; set; }
|
||||||
|
|
||||||
|
public int P1 { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsOwnsOne = true)]
|
||||||
|
public MyVO MyVO { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MyVO
|
||||||
|
{
|
||||||
|
public Guid VoId { get; set; }
|
||||||
|
|
||||||
|
public Guid GuidP1 { get; set; }
|
||||||
|
|
||||||
|
public Guid GuidP2 { get; set; }
|
||||||
|
}
|
||||||
|
public class UnitAddressadfafa2221
|
||||||
|
{
|
||||||
|
public string Street { get; set; }
|
||||||
|
public string City { get; set; }
|
||||||
|
|
||||||
|
public string ZipCode { get; set; }
|
||||||
|
[SugarColumn(ColumnDataType ="VARCHAR(20)",SqlParameterDbType = typeof(EnumToStringConvert))]//CommonPropertyConvertORM自带的
|
||||||
|
public DbType DbType { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
public class UnitCustomeradfafas1
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public int CustomerId { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
[SqlSugar.SugarColumn(IsOwnsOne = true)]
|
||||||
|
public UnitAddressadfafa2221 Address { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace OrmTest
|
namespace OrmTest
|
||||||
{
|
{
|
||||||
@ -112,7 +113,47 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
throw new Exception("unit error");
|
throw new Exception("unit error");
|
||||||
}
|
}
|
||||||
|
db.CodeFirst.InitTables<UnitafasMyEntity>();
|
||||||
|
db.Insertable(new UnitafasMyEntity()
|
||||||
|
{
|
||||||
|
Id=Guid.NewGuid(),
|
||||||
|
P0="",
|
||||||
|
P1=1,
|
||||||
|
MyVO=new MyVO() {
|
||||||
|
GuidP1=Guid.NewGuid(),
|
||||||
|
GuidP2=Guid.NewGuid(),
|
||||||
|
VoId=Guid.NewGuid()
|
||||||
}
|
}
|
||||||
|
}).ExecuteCommand();
|
||||||
|
var list5 = db.Queryable<UnitafasMyEntity>()
|
||||||
|
.Select(e => new
|
||||||
|
{
|
||||||
|
e.Id,
|
||||||
|
e.MyVO.GuidP1,
|
||||||
|
e.MyVO.GuidP2
|
||||||
|
})
|
||||||
|
.ToListAsync().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class UnitafasMyEntity
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public string P0 { get; set; }
|
||||||
|
|
||||||
|
public int P1 { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsOwnsOne = true)]
|
||||||
|
public MyVO MyVO { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MyVO
|
||||||
|
{
|
||||||
|
public Guid VoId { get; set; }
|
||||||
|
|
||||||
|
public Guid GuidP1 { get; set; }
|
||||||
|
|
||||||
|
public Guid GuidP2 { get; set; }
|
||||||
}
|
}
|
||||||
public class UnitAddressadfafa2221
|
public class UnitAddressadfafa2221
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>SqlSugar.GBaseCore</id>
|
<id>SqlSugar.GBaseCore</id>
|
||||||
<version>5.1.4.152</version>
|
<version>5.1.4.166</version>
|
||||||
<authors>sunkaixuan</authors>
|
<authors>sunkaixuan</authors>
|
||||||
<owners>Landa</owners>
|
<owners>Landa</owners>
|
||||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||||
|
Loading…
Reference in New Issue
Block a user