多对多导航插入,在中间表中增加自定义参数 导航插入要怎么查询 返回

多对多导航插入,在中间表中增加自定义参数 导航插入要怎么查询,数据结构如下
//实体
public class ABMapping1
{
[SugarColumn(IsPrimaryKey = true)]//中间表可以不是主键
public int AId { get; set; }
[SugarColumn(IsPrimaryKey = true)]//中间表可以不是主键
public int BId { get; set; }
public string AName { get; set; }
}
public class A1
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
public string Name { get; set; }
[Navigate(typeof(ABMapping1), nameof(ABMapping1.AId), nameof(ABMapping1.BId))]//注意顺序
public List<B1> BList { get; set; }//只能是null不能赋默认值
}
public class B1
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
public string Name { get; set; }
[Navigate(typeof(ABMapping1), nameof(ABMapping1.BId), nameof(ABMapping1.AId))]//注意顺序
public List<A1> AList { get; set; }//只能是null不能赋默认值
}
热忱回答(3)
-
lang VIP0
2025/1/2中间表中的AName 是新增字段
0 回复 -
fate sta VIP0
2025/1/2只能直接查中间表
0 回复 -
lang VIP0
2025/1/3数据插入呢,先导航插入,再查中间表给AName赋值,目前我想到的就这一种方式。还有其它方式吗
0 回复