这是我的数据库设计
为此,我通过EF Core中的以下查询检索数据。
from u in _context.Users
from r in _context.Roles.Include("RoleApplicationActivity")
from raa in _context.RoleAppActivities.Include("Application").Include("Activity").Include("Role")
from app in _context.Applications.Include(a => a.RoleApplicationActivity)
from ac in _context.Activities.Include(a => a.RoleApplicationActivity)
where u.Id == id
select new FullUser
{
User = u,
Roles = u.Roles,
RoleAppActivity = r.RoleApplicationActivity
}
即使在我检查导航属性的值时使用包含它们也是空的。想知道我错过了什么。帮助赞赏。
在运行此查询之前,如果加载所有必需的实体,则EF Core会为我填充数据。想知道这是否是好方法。
_context.Applications.Load();
_context.Roles.Load();
_context.Activities.Load();