导航属性否支持符合索引 返回
主表 、子表想通过 PlantId 、ItemId 做关联,导航属性如何写?
主表:
public class Wo
{
public decimal Id { get; set; }
/// <summary>
/// 生产订单号
/// </summary>
public string Code { get; set; }
/// <summary>
/// 工厂ID
/// </summary>
public decimal PlantId { get; set; }
/// <summary>
/// 物料id
/// </summary>
public decimal ItemId { get; set; }
/// <summary>
/// 关联的物料
/// </summary>
[Navigate(NavigateType.ManyToOne, nameof(ItemId))]
public Item Item { get; set; }
}
子表:
public class Item
{
public decimal Id { get; set; }
/// <summary>
/// 工厂ID
/// </summary>
public decimal PlantId { get; set; }
/// <summary>
/// 物料编号
/// </summary>
public string Code { get; set; }
/// <summary>
/// 物料描述
/// </summary>
public string Desc { get; set; }
}
热忱回答(3)
-
fate sta VIP02023/9/18
[Navigate(NavigateType.ManyToOne, nameof(ItemId))] public Item Item { get; set; }
下面的要加上主键
public class Item { [SugarColumn(IsPrimaryKey=true)] public decimal Id { get; set; }
var list=db.Queryable<Wo>().Includes(it=>it.Item).ToList();
0 回复 -
fate sta VIP02023/9/18
如果想多字段看
NavigateType.Dynamic 用法
0 回复 -
lonely boy VIP02023/9/18
@fate sta:谢谢,如果能在特性里面配置,那就更香了
0 回复