from子句中的表达式类型不正确。调用“ SelectMany”时类型推断失败

时间:2018-10-30 12:57:04

标签: c# linq

using (RPasEntities entities = new RPasEntities())
        {
            response = (from ent in entities.Settings
                        join own in entities.Settings on ent.SystemSettID equals own.MySett
                           into RightTable1
                        from doce1 in RightTable1.DefaultIfEmpty
                        join doc in entities.AllDocuments on ent.SystemSettID equals doc.SystemSettID
                            into RightTableResults
                        from doce in RightTableResults.DefaultIfEmpty
                        where doce1.SystemSettID = userSettingID
                        select new UserViewModel { ID = doce1.SystemSettID, UserName = doce1.UserName == null ? " " : doce1.UserName, MyPassword = doce1.MyPassword, FirstName = doce1.FirstName, LastName = doce1.LastName, SettingName = doce1.SettingName, MySett = doce1.MySett, SettingOwner = doce1.FirstName == null ? " " : doce1.FirstName & " " & doce1.LastName & "(" & doce1.UserName & ")", MyCreator = doce1.MyCreator, MyType = doce1.MyType, Email = doce1.Email, Phone = doce1.Phone, Address = doce1.Address, MyCity = doce1.MyCity, MyState = doce1.MyState, MyZip = doce1.MyZip, Country = doce1.Country, Status = doce1.Status, MyPlan = doce1.MyPlan, CreatedOn = doce1.CreatedOn, TypeLicense = doce.TypeLicense, AuthorizingState = doce.AuthorizingState, NameLicensing = doce.NameLicensing, LicenseNumber = doce.LicenseNumber, LicenseExpiration = doce.LicenseExpiration, LicenseURL = doce.LicenseURL, AdvancedDegree = doce.AdvancedDegree, MajorAreaDegree = doce.MajorAreaDegree, YearDegree = doce.YearDegree, InstitutionDegree = doce.InstitutionDegree, ListPsychometrics = doce.ListPsychometrics, ListInterpret = doce.ListInterpret, ListTraining = doce.ListTraining, ListRor = doce.ListRor, CourseTitle = doce.CourseTitle, CourseNumber = doce.CourseNumber, CourseUniversity = doce.CourseUniversity, CourseDepartment = doce.CourseDepartment, CourseURL = doce.CourseURL, CourseEnrollment = doce.CourseEnrollment, CourseProtocols = doce.CourseProtocols, CourseDirectorName = doce.CourseDirectorName, CourseDirectorEmail = doce.CourseDirectorEmail, ProjectTitle = doce.ProjectTitle, ProjectUniversity = doce.ProjectUniversity, ProjectDepartment = doce.ProjectDepartment, ProjectSupervisorName = doce.ProjectSupervisorName, ProjectSupervisorEmail = doce.ProjectSupervisorEmail, ProjectURL = doce.ProjectURL, ProjectSample = doce.ProjectSample, ProjectCompletion = doce.ProjectCompletion, ProjectVenue = doce.ProjectVenue, CanUse = doce.CanUse }).FirstOrDefault();


        }
        return response;

我正在将Vb.Net代码转换为C#.Net,但是在此代码中我面临此问题 在第6行“来自RightTable.DefaultIfEmpty中的doce1”中,此行来自error。如下图所示

enter image description here

0 个答案:

没有答案