假设我的域中有以下对象。
[TableName("work_space")]
public class WorkSpace
{
public long Id { get; set; }
[Column(Name="owner_id")]
public long OwnerId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public IEnumerable<int> OrgIds { get; set; }
public IEnumerable<int> SettingIds { get; set; }
public IEnumerable<int> UserIds { get; set; }
public IEnumerable<long> WorkViewIds { get; set; }
}
这是获取我需要的数据的一种方法。
SELECT ws.*, wsu.user_id as UserId, wss.setting_id as SettingId, wso.org_id as OrgId, wv.id as WorkViewId
FROM work_space ws
LEFT OUTER JOIN work_space_user wsu ON ws.id = wsu.work_space_id
LEFT OUTER JOIN work_space_setting wss ON ws.id = wss.work_space_id
LEFT OUTER JOIN work_space_org wso ON ws.id = wso.work_space_id
LEFT OUTER JOIN work_view wv ON ws.id = wv.work_space_id
WHERE ws.id = @0
这通常在 NPoco 中是如何完成的?我会使用多结果集获取吗?某种获取一对多?我将我的 ID 集合标记为结果列还是忽略列?我只是在文档中找不到任何这样的例子。