$ project或$ group仅在多个左联接上不支持<document>

时间:2019-04-26 07:59:43

标签: c# .net mongodb linq mongodb-.net-driver

我知道此错误在here中给出了答案。但就我而言,我不是直接投影任何文档。当我使用内部联接而不是user集合中的左联接时,此方法工作正常。 SO的任何内容对我都不起作用

            var query = from
                    his in levelsOfApprovalHistory
                    where his.ReferenceNo == referenceNumber
                    join serv in services on his.Service.ServiceId equals serv.ServiceId
                    join st in status on his.StatusDetails.StatusId equals st.StatusValue
                    join us in user on his.User.PoliceId equals us.PoliceId into u
                    from usr in u.DefaultIfEmpty()
                    join emp in employee on usr.Employee.EmployeeID equals emp.EmployeeID into ps
                    from p in ps.DefaultIfEmpty()
                    select new ApplicationStatusHistoryDTO()
                    {
                        ID = his.ID,
                        ReferenceNo = his.ReferenceNo,
                        Comments = his.Comments,
                        RequestorNameEn = his.RequestorNameEn,
                        RequestorNameAr = his.RequestorNameAr,
                        UTCDate = his.UTCDate,
                        Service = new Service()
                        {
                            ServiceId = his.Service.ServiceId,
                            ServiceName = serv.ServiceName,
                            ServiceNameAr = serv.ServiceNameAr
                        },
                        StatusDetails = new FollowUpStatus()
                        {
                            StatusId = st.StatusId,
                            StatusNameEn = st.StatusNameEn,
                            StatusNameAr = st.StatusNameAr,
                            StatusValue = st.StatusValue,
                            StyleClass = st.StyleClass,
                            IsPrimary = st.IsPrimary
                        },
                        EmployeeDetails = new Employee()
                        {
                            EmployeeID = p.EmployeeID,
                            FirstName = p.FirstName,
                            EnglishName = p.EnglishName,
                            UserCode = usr.MilitaryNumber
                        },
                        Level = new Levels()
                        {
                            LevelID = his.Level.LevelID,
                            LevelEnName = his.Level.LevelEnName,
                            LevelArName = his.Level.LevelArName,
                            Service = new Service()
                            {
                                ServiceId = his.Level.Service.ServiceId
                            },
                            IsFinal = his.Level.IsFinal
                        }
                    };

0 个答案:

没有答案