C#存储库ICollection导航错误

时间:2018-09-19 09:51:01

标签: entity-framework asp.net-web-api asp.net-core-2.1 ef-core-2.1

我被困住了,需要帮助。 通过以下方法检查用户权限

                    if (User.IsInRole("CanAccessOnlyOwnDepartmentRequest"))
                    {
                        //CanAccessOnlyOwnDepartmentRequest yetkisinie sahipse
                        itemResult = await Repository.PaginatedListDescAsync(p => p.BranchAsset.BranchId == userBranchId &&
                            (p.AssigningUser.Employee.DepartmentId == branchUser.DataResult.Employee.DepartmentId ||
                                p.AssignedUser.Employee.DepartmentId == branchUser.DataResult.Employee.DepartmentId) &&
                            (p.Assignments.LastOrDefault().AssignUser.Employee.DepartmentId == branchUser.DataResult.Employee.DepartmentId),
                            p => p.Id, paging.PageIndex, paging.PageSize,GetNavigation:true);
                    }

我想做的是,我要检查“请求->分配收集最后一项的分配用户和分配的用户部门ID是否等于请求结果的用户”。

这是我的评估部分的请求实体定义

    private ICollection<RequestAssignment> _assignments;
    public virtual ICollection<RequestAssignment> Assignments
    {
        get => LazyLoader?.Load(this, ref _assignments);
        set => _assignments = value;
    }

我在必要的实体属性上使用EF Core 2.1和LazyLoading

我面临的错误:

未为类型“ System.Collections.Generic.IAsyncEnumerable`1 [Q.Entity.Corporate.EmployeeEntity.Employee]”定义属性“ System.Guid DepartmentId” 参数名称:属性

EDİT: 请求类别

    public Guid? BranchAssetId { get; set; }
    public BranchAsset BranchAsset { get; set; }

    public Guid AssigningUserId { get; set; }
    public BranchUser AssigningUser { get; set; }

    public Guid AssignedUserId { get; set; }
    public BranchUser AssignedUser { get; set; }

    public Guid StateTypeId { get; set; }
    public RequestStateType StateType { get; set; }

    public Ticket Ticket { get; set; }
    public ICollection<RequestFeedback> Feedbacks { get; set; }
    public ICollection<RequestState> States { get; set; }
    public ICollection<RequestProcess> Process { get; set; }
    public ICollection<RequestMessage> Messages { get; set; }
    public ICollection<RequestAssignment> Assignments { get; set; }

RequestAssignment类:

    public Guid RequestId { get; set; }
    public Request Request { get; set; }

    public Guid AssignUserId { get; set; }
    public BranchUser AssignUser{ get; set; }

    public Guid AssignedUserId { get; set; }
    public BranchUser AssignedUser{ get; set; }

    public string Note { get; set; }

BranchUser类别:

    public Guid EmployeeId { get; set; }
    public Employee Employee{ get; set; }

    public Guid BranchId { get; set; }
    public Branch Branch { get; set; }

    public Guid? ApplicationUserId { get; set; }
    public ApplicationUser ApplicationUser { get; set; }

    public ICollection<BranchUserRequestApproval> RequestApprovals { get; set; }

员工阶层

    public Guid DepartmentId { get; set; }
    public Department Department { get; set; }
    public Person PersonInformation { get; set; }

    public Guid BranchId { get; set; }
    public Branch Branch { get; set; }

0 个答案:

没有答案