mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-30 04:45:54 +08:00
Update unit test
This commit is contained in:
parent
874f50ae49
commit
0e66e75dde
@ -22,10 +22,12 @@ namespace OrmTest
|
||||
|
||||
db.CodeFirst.InitTables<Country1111>();
|
||||
db.CodeFirst.InitTables<Province1111>();
|
||||
db.CodeFirst.InitTables<Country111Info>();
|
||||
db.CodeFirst.InitTables<Country111Info, City1111,Street1111>();
|
||||
db.DbMaintenance.TruncateTable("Country_1111");
|
||||
db.DbMaintenance.TruncateTable("Province_1111");
|
||||
db.DbMaintenance.TruncateTable("Country111Info");
|
||||
db.DbMaintenance.TruncateTable("City_1111");
|
||||
db.DbMaintenance.TruncateTable("Street_1111");
|
||||
var c = new Country1111()
|
||||
{
|
||||
Id=1,
|
||||
@ -51,6 +53,22 @@ namespace OrmTest
|
||||
|
||||
db.Insertable(c).ExecuteCommand();
|
||||
db.Insertable(ps).ExecuteCommand();
|
||||
db.Insertable(new City1111() {
|
||||
Id=1, Name="南通", pid=1001
|
||||
}).ExecuteCommand();
|
||||
db.Insertable(new City1111()
|
||||
{
|
||||
Id = 2,
|
||||
Name = "苏州",
|
||||
pid = 1001
|
||||
}).ExecuteCommand();
|
||||
//db.Insertable(ps).ExecuteCommand();
|
||||
db.Insertable(new Street1111()
|
||||
{
|
||||
Id = 1,
|
||||
Name = "南通小区",
|
||||
cid = 1
|
||||
}).ExecuteCommand();
|
||||
db.Insertable(new Country111Info { Id=1, Name="infoa"}).ExecuteCommand();
|
||||
db.Aop.OnLogExecuted = (sq, p) =>
|
||||
{
|
||||
@ -63,6 +81,11 @@ namespace OrmTest
|
||||
var list2 = db.Queryable<Country1111>()
|
||||
.Includes(x => x.Provinces.OrderByDescending(x111 => x111.Id).ToList())
|
||||
.ToList();
|
||||
var list3 = db.Queryable<Country1111>()
|
||||
.Includes(it=>it.Provinces,it=>it.city1111s,it=>it.streets)
|
||||
.Where(z=>z.Provinces.Any(y=>y.city1111s.Any(x=>x.streets.Any())))
|
||||
.ToList();
|
||||
if (list3.Count() != 1) throw new Exception("unit error");
|
||||
}
|
||||
|
||||
[SugarTable("Country_1111")]
|
||||
@ -90,12 +113,34 @@ namespace OrmTest
|
||||
[SugarTable("Province_1111")]
|
||||
public class Province1111
|
||||
{
|
||||
[SqlSugar.SugarColumn( ColumnName = "pid")]
|
||||
[SqlSugar.SugarColumn( ColumnName = "pid",IsPrimaryKey =true)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[SugarColumn(ColumnName = "coid")]
|
||||
public int CountryId { get; set; }
|
||||
[Navigate(NavigateType.OneToMany,nameof(City1111.pid))]
|
||||
public List<City1111> city1111s { get; set; }
|
||||
}
|
||||
|
||||
[SugarTable("City_1111")]
|
||||
public class City1111
|
||||
{
|
||||
[SqlSugar.SugarColumn(ColumnName = "cid",IsPrimaryKey =true)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int pid { get; set; }
|
||||
[Navigate(NavigateType.OneToMany, nameof(Street1111.cid))]
|
||||
public List<Street1111> streets { get; set; }
|
||||
|
||||
}
|
||||
[SugarTable("Street_1111")]
|
||||
public class Street1111
|
||||
{
|
||||
[SqlSugar.SugarColumn(ColumnName = "sid",IsPrimaryKey =true)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int cid { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user