设置导航属性后。中间表的更新问题 返回

----A表结构----
[SugarTable("fy_expense_bill")]
public class ExpenseDTO
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
public string DocNo { get; set; }//单号
[Navigate(typeof(ECDTO),nameof(ECDTO.ExpenseNo),nameof(ECDTO.ContractNo),nameof(DocNo),nameof(ContractDTO.ContractNo))]//设置导航属性
public List<ContractDTO> Contracts { get; set; }
}
----B表结构----
[SugarTable("fy_costcontract")]
public class ContractDTO
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
public string ContractNo { get; set; }//单号
[Navigate(typeof(ECDTO),nameof(ECDTO.ContractNo),nameof(ECDTO.ExpenseNo),nameof(ContractDTO.ContractNo),nameof(ExpenseDTO.DocNo))]//设置导航属性
public List<ExpenseDTO> expenses { get; set; }
}
---中间表结构---
[SugarTable("fy_Relative_ExpenseContract")]
public class ECDTO
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
public string ExpenseNo { get; set; }
public string ContractNo { get; set; }
}
---代码-----
public string SaveData(ExpenseDTO expense)
{
//根据expense表的ExpenseNo,到中间表删除数据,然后插入新的数据
_db.UpdateNav(expense)
.Include(c4 => c4.Contracts)
.ExecuteCommand();
}
[Sql]:DELETE FROM [fy_Relative_ExpenseContract] WHERE [ExpenseNo] IN (7) ---这个是log
应该是取的docno的值,为什么打印sql出来是取的expense表的id
请教下,可能是哪些有问题
热忱回答(3)
-
fate sta VIP0
2024/10/30+5的重载多对多只支持了查询
0 回复 -
fate sta VIP0
2024/10/30这个我后期也支持一下更新
0 回复 -
a1b2c3c VIP0
2024/10/30好的,我想其他办法解决
0 回复