mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 16:18:47 +08:00
BUG
This commit is contained in:
parent
f7d8e5a0d1
commit
1664dd32aa
@ -102,6 +102,43 @@ namespace OrmTest
|
|||||||
.Mapper<A,B,ABMapping>(it => ManyToMany.Config(it.AId,it.BId))
|
.Mapper<A,B,ABMapping>(it => ManyToMany.Config(it.AId,it.BId))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
Db.CodeFirst.InitTables<ABMap, TableA, TableB>();
|
||||||
|
Db.DbMaintenance.TruncateTable("TableA");
|
||||||
|
Db.DbMaintenance.TruncateTable("Tableb");
|
||||||
|
Db.DbMaintenance.TruncateTable("ABMap");
|
||||||
|
Db.Insertable(new TableA() { id=1, Name = "A1" }).ExecuteCommand();
|
||||||
|
Db.Insertable(new TableA() {id=2, Name = "A1" }).ExecuteCommand();
|
||||||
|
Db.Insertable(new TableB() { id=1, Name = "B1" }).ExecuteCommand();
|
||||||
|
Db.Insertable(new TableB() { id=2, Name = "B2" }).ExecuteCommand();
|
||||||
|
Db.Insertable(new ABMap() { Aid=1,Bid=1 }).ExecuteCommand();
|
||||||
|
Db.Insertable(new ABMap() { Aid = 1, Bid = 2 }).ExecuteCommand();
|
||||||
|
Db.Insertable(new ABMap() { Aid = 2, Bid = 1 }).ExecuteCommand();
|
||||||
|
Db.Insertable(new ABMap() { Aid = 2, Bid =2 }).ExecuteCommand();
|
||||||
|
var list9= Db.Queryable<TableA>()
|
||||||
|
.Mapper<TableA, TableB, ABMap>(it => ManyToMany.Config(it.Aid, it.Bid)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class ABMap{
|
||||||
|
public int Aid { get; set; }
|
||||||
|
public int Bid { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TableA{
|
||||||
|
|
||||||
|
[SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
|
||||||
|
public int id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
[SugarColumn(IsIgnore =true)]
|
||||||
|
public List<TableB> Childlist { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class TableB
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,11 +130,13 @@ namespace SqlSugar
|
|||||||
|
|
||||||
//A
|
//A
|
||||||
var aEntity = this.Context.EntityMaintenance.GetEntityInfo(aType);
|
var aEntity = this.Context.EntityMaintenance.GetEntityInfo(aType);
|
||||||
var aPropertyName = aEntity.Columns.FirstOrDefault(it => it.IsPrimarykey == true).PropertyName;
|
var aPropertyName = aEntity.Columns.FirstOrDefault(it => it.IsPrimarykey == true)?.PropertyName;
|
||||||
|
Check.Exception(aPropertyName == null, aEntity.EntityName + " no primary key");
|
||||||
|
|
||||||
//B
|
//B
|
||||||
var bEntity = this.Context.EntityMaintenance.GetEntityInfo(bType);
|
var bEntity = this.Context.EntityMaintenance.GetEntityInfo(bType);
|
||||||
var bProperty = bEntity.Columns.FirstOrDefault(it => it.IsPrimarykey == true).PropertyName;
|
var bProperty = bEntity.Columns.FirstOrDefault(it => it.IsPrimarykey == true)?.PropertyName;
|
||||||
|
Check.Exception(bProperty == null, bEntity.EntityName + " no primary key");
|
||||||
var bDbFiled = bEntity.Columns.FirstOrDefault(it => it.IsPrimarykey == true).DbColumnName;
|
var bDbFiled = bEntity.Columns.FirstOrDefault(it => it.IsPrimarykey == true).DbColumnName;
|
||||||
this.Mapper((it,cache) =>
|
this.Mapper((it,cache) =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user