小编dsa*_*cho的帖子

如何使用NPoco在同一个表中保存嵌套对象?

我有一个这样的课:

public class AuthEntity 
{
  public int Id { get; set; }

  public AuthResource Resource { get; set; }

  public int ActionId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

AuthResource在哪里:

public class AuthResource 
{
  public long ResourceId { get; private set; }

  public int ResourceType { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)

存储数据的表具有以下字段:

  • ID
  • RESOURCEID
  • 的ResourceType
  • ActionId

我可以很好地阅读AuthEntity(包括Resource属性),但我不知道如何插入AuthEntity记录.NPoco说没有资源字段.如何将嵌套对象字段映射到表字段?

谢谢

c# npoco

5
推荐指数
1
解决办法
716
查看次数

标签 统计

c# ×1

npoco ×1