2

似乎有很多方法可以实现这一点,但我试图弄清楚.net Core 2 / EF core 2.0 的最佳实践是什么。

我有诸如

public class Company {
    public Guid CompanyID {get; set;}
    public ICollection<Order> Orders {get; set;}
    ...
    public ICollection<UserLocation> UserLocations { get; set; }
}

public class Order {
    public Guid CompanyID { get; set; }
    public Company Company { get; set; }
    public DateTime OrderDate {get; set;}
}

public class UserLocation {
    public Guid CompanyID { get; set; }
    public Company Company { get; set; }

    public String UserId { get; set; }
    public ApplicationUser ApplicationUser { get; set; }
}

对于我的公司索引页面,我只希望显示用户有权访问的公司。可以为此使用全局过滤器还是在这种情况下不起作用?

谢谢

4

1 回答 1

0

这取决于,如果用户不应该访问公司,全局过滤器是一个很好的解决方案。当要求仅适用于索引页时,您最好对索引页进行特定查询。

于 2017-12-04T21:04:41.933 回答